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 fix this? Any Suggestion would be great.
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);
Make Global or get global permissions to the object responsible for the instance of add()
global $wp_object_responsible;
function myplugin_check_fields($errors, $sanitized_user_login, $user_email) {
global $wp_object_responsible; //edit here
$errors->add( 'demo_error', __('<strong>ERROR</strong>: This is a demo error. Registration halted.','mydomain') );
return $errors;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.