Support

Account

Home Forums ACF PRO Multiple user acf_forms on one page with validation Reply To: Multiple user acf_forms on one page with validation

  • Hi @deejayfaggyfag

    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 🙂