Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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();}
}
share|improve this question
    
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 at 11:26
    
Are you using WP multisite? registration_errors hook is called after user registration, but not on WP multiste. –  user42826 Feb 19 at 14:37

1 Answer 1

up vote 0 down vote accepted

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;
}
share|improve this answer
    
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 ? –  Ryan Babu Feb 20 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 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 –  Ryan Babu Feb 20 at 9:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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