Home › Forums › Front-end Issues › acf form validation only on certain page › Reply To: acf form validation only on certain page
Hi @sami616
Could you please tell me if this “registration template” is on front end or back end?
If it is on the front end, I think you can add a hidden input on your form to mark it as a registration page. Maybe something like this:
acf_form(array(
'html_after_fields' => '<input type="hidden" name="acf[register]" value="true"/>',
));
After that, you can check this hidden input using the $_POST
variable. It should be something like this:
add_filter('acf/validate_value/name=sr_email', 'my_acf_validate_email', 10, 4);
function my_acf_validate_email( $valid, $value, $field, $input ){
if( !$valid ) {
return $valid;
}
if(($_POST['acf']['register'] == 'true') && email_exists($value)){
$valid = 'Email already in use';
}
return $valid;
}
I hope this helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.