The Hook registration_errors was not called

I can’t validate the custom fields in my plugin. I want to skip some registration on WordPress. My code snippet is here:

add_filter( 'registration_errors', 'reg_user_register', 10, 3);
function reg_user_register($errors, $sanitized_user_login, $user_email){
    global $wpdb;
    echo "<pre>";  /*need the values that are post from registration page*/
    print_r($_POST);
    exit();}
}

Related posts

1 comment

  1. You are not using the registration_errors hook properly. It should look like this:

    add_filter( 'registration_errors', 'reg_user_register', 10, 3);
    function reg_user_register($errors, $sanitized_user_login, $user_email){
        $custom_reg_field1 = $_POST["custom_reg_field1"];
        // add error checking here
        if ( empty($custom_reg_field1) ) {
            $errors->add('custom_reg_field1', __( 'Please enter a reg_field1.' ) );
        }
        return $errors;
    }
    

Comments are closed.