我正在使用WordPress插件,并且想创建一个新的登录错误消息,如下所示:
我正在使用此代码:
add_filter( 'login_errors', $error );
$error = '<strong>ERROR:</strong> Code was invalid.';
但是,我遇到了3个错误。
注意:未定义的变量:第119行的\ wp-content \ plugins \ directory \ [cut] .php中的错误
注意:925行的[cut] plugin.php中未定义的偏移量:0
注意:第943行的[cut] plugin.php中未定义的偏移量:0
我试图将$error
过滤器置于上方,但这也不起作用。
怎么了??
阅读有关add_filter函数的文档。
第二个参数是:
$ function_to_add(可调用)(必需)应用过滤器时要运行的回调。
它应该是带有函数名称的字符串。在您的情况下,以下代码应该可以工作:
function return_custom_error() {
$error = '<strong>ERROR:</strong> Code was invalid.';
return $error;
}
add_filter( 'login_errors', 'return_custom_error' );
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句