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 have validate the custom field in registration form, I read out the codex of wordpress so that itself i do this way. But I figure out it throws error like this one

Call to a member function add() on a non-object  I don't know why this should happen. How can i overcome this. 


function myplugin_check_fields($errors, $sanitized_user_login, $user_email) {

        $errors->add( 'demo_error', __('<strong>ERROR</strong>: This is a demo error. Registration halted.','mydomain') );

        return $errors;


    add_filter('registration_errors', 'myplugin_check_fields', 10, 3);
share|improve this question

Seems like this might be a bug in a plug-in or theme. From the Codex:

The form will not create a new user if any errors are returned. Notice: The function must return the variable $errors in any case (even when there is no error in your logic), otherwise the function may cause this problem: Fatal error: Call to a member function get_error_code() on a non-object.

Deactivate all other plug-ins to find which is causing it. If it's still persisting, switch the theme to TwentyEeven. Once you've identified the culprit, you'll need to search the code for the error - somewhere they'll be doing something similar to you, but not returning $errors.

share|improve this answer

Your Answer


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.