I need to add a field to the user registration form and then validate it before I add a new user to my WordPress

I know how to hook into the registration form via add_filter('register_form', 'my_function');

But how do I hook into the registration process before the user registers? Hence I do not want add_action('user_register','my_other_function');.

2 Answers 2


You need to create your own hook for registration_errors filter:

add_filter( 'registration_errors', 'wpse8170_registration_errors', 10, 3 );
function wpse8170_registration_errors( $errors, $sanitized_user_login, $user_email ) {
    if ( /* something happens */ ) {
        $errors->add( 'myexception_code', 'This is my message' );

    return $errors;
  • im getting Parse error: syntax error, unexpected '10' (T_LNUMBER)
    – t q
    Commented Apr 25, 2016 at 18:17
  • @tq looks like you're doing something wrong. Forgot comma? Commented Apr 27, 2016 at 12:52

Take a look at the WordPress Codex: Customizing The Registration Form

Theme and plugin developers can customize WordPress's built-in user registration page through the use of hooks.

Customizing the registration form involves utilizing the following three hooks:

  1. register_form
    Allows rendering of new HTML form elements.
  2. registration_errors
    Perform validation on form registration fields.
  3. user_register
    Save custom form data.
  • Haha...thanks @EugeneManuilov...I was just thinking, wait a minute isn't that pretty good documented, I guess for an answer it's a bit on the edge though. Commented Oct 10, 2013 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.