0
我已经在注册表单中验证了自定义字段,我宣读了wordpress的注释,以便我自己可以这样做。但我知道它会抛出像这样的错误在wordpress中注册表单验证
Call to a member function add() on a non-object
我不知道为什么会发生这种情况。我怎样才能解决这个问题?任何建议都会很棒。
代码:
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);
使用全局代码在这里,似乎它知道添加,但它给了你一个错误,所以尝试使一些变量全局变量与另一个页面中的add()有关联,检查初始化 –