Home › Forums › ACF PRO › Multiple user acf_forms on one page with validation › Reply To: Multiple user acf_forms on one page with validation
That’s sure weird. Could you please open a new ticket so it can be passed to the plugin author? You can open a new ticket here: https://support.advancedcustomfields.com/new-ticket. Also, please don’t forget to explain the issue again and provide the link to this thread.
As a workaround, you can get the correct data from the _acf_form
form data like this:
function my_validate_value_email($valid, $value, $field, $input) {
// get the encrypted form data
$data = acf_extract_var($_POST, '_acf_form');
// decode the form data
$data = @json_decode(base64_decode($data), true);
// get the correct post ID
$user_id = $data['post_id'];
$user_id = substr($_POST['post_id'], 5);
$user = get_user_by('email', $value);
return $user && $user->ID != $user_id ? __('Email already exists', 'text-domain') : $valid;
}
add_filter('acf/validate_value/name=email', 'my_validate_value_email', 10, 4);
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.