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.
Code:
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);
Seems like this might be a bug in a plug-in or theme. From the Codex:
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
.