WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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');.

share|improve this question

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;
share|improve this answer
im getting Parse error: syntax error, unexpected '10' (T_LNUMBER) – t q Apr 25 at 18:17
@tq looks like you're doing something wrong. Forgot comma? – Eugene Manuilov Apr 27 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.
share|improve this answer
+1 for good reference ;) – Eugene Manuilov Oct 10 '13 at 21:11
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. – ialocin Oct 10 '13 at 21:27

Your Answer


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