Fires validation when specific form field is completed.


(int) Field ID.
(array) Original raw/unsanitized field value submitted for the field.
(array) Processed form settings/data, prepared to be used later.



More Information

The wpforms_process_validate_email filter is applied to an array for Email form field. This function can be used for all form fields do_action( "wpforms_process_validate_{$field_type}", $field_id, $field_submit, $form_data ).

It’s important to note that field values are not sanitized until later on in the processing, at wpforms_process_format_{$field_type}.


In this example shown below, the function will check the Email form field.

 * Whitelist email domains from your WPForms.
 * @link
 * @param int     $field_id        Field ID.
 * @param array   $field_submit    Unsanitized field value submitted for the field.
 * @param array   $form_data       Form data and settings.

function wpf_dev_whitelist_domains( $field_id, $field_submit, $form_data ) {
    $domain          = substr( strrchr( $field_submit, "@" ), 1 );
    $whitelist       = array( '', '' );

    if( ! in_array( $domain, $whitelist ) ) { 
        wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Email domain not accepted!', 'wpforms' );
add_action('wpforms_process_validate_email', 'wpf_dev_whitelist_domains', 10, 3 );

Snippet Reference: How to Restrict Email Domains