1

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();}
}
2
  • What exactly are you trying to do? Please file an edit and explain. And please also keep in mind: Questions are references for later visitors. Format and write them as good as you can.
    – kaiser
    Feb 19, 2014 at 11:26
  • Are you using WP multisite? registration_errors hook is called after user registration, but not on WP multiste.
    – user42826
    Feb 19, 2014 at 14:37

1 Answer 1

0

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;
}
3
  • Thanks for your answer . There is no problem on parameter passing. Is any option to modify,validate the user-edit.php(admin side new user creation) . Any hooks for that ?
    – Babu
    Feb 20, 2014 at 5:31
  • user-edit.php is not user registration. User registration is wp-login.php?action=register... which is what registration_error hooks into. If you wanted to hook into user-edit.php, I believe it is user_profile_update_errors
    – user42826
    Feb 20, 2014 at 6:40
  • Thank you so much i resolve my problem i already use this hook on my plugin .. i just add some conditions . great answer thank you again
    – Babu
    Feb 20, 2014 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.