Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在wordpress登录时显示错误消息_Php_Wordpress - Fatal编程技术网

Php 在wordpress登录时显示错误消息

Php 在wordpress登录时显示错误消息,php,wordpress,Php,Wordpress,当验证码不正确时,我想在wp登录表单上显示错误消息。。我正在使用“登录重定向”和“登录错误”过滤器..这是我的代码 add_filter( 'login_redirect', 'captcha_login_check', 10, 3); add_filter( 'login_errors', 'captcha_login_post' ); function captcha_login_check($username, $password) { if (isset($_POST["security

当验证码不正确时,我想在wp登录表单上显示错误消息。。我正在使用“登录重定向”和“登录错误”过滤器..这是我的代码

add_filter( 'login_redirect', 'captcha_login_check', 10, 3);
add_filter( 'login_errors', 'captcha_login_post' );
function captcha_login_check($username, $password)
{
if (isset($_POST["security_check"])) 
{
    $code = str_decrypt($_POST["security_check"]);
    if (!( empty($code)) && !($code == $_POST['security_code'] ) && ($password == false))
    {
        function captcha_login_post($error)
        {
            return $error."<p><span style='color:red'>Error, the Security Code does not match. Please Try Again.</span><br></p>";
        }

    }
    else if(!( empty($code)) && !($code == $_POST['security_code'] ) && ($password == true))
    {
        $url = get_site_url().'/wp-login.php'; 
        header('Location:'.$url);
        echo  "<p><span style='color:red'>Error, the Security Code does not match. Please Try Again.</span><br></p>";

    }
    else
    {
        $url = get_site_url().'/wp-admin'; 
        header('Location:'.$url);
    }
}
add_filter('login_redirect','captcha_login_check',10,3);
添加过滤器('login\u errors'、'captcha\u login\u post');
函数验证码\登录\检查($username,$password)
{
如果(isset($_POST[“安全检查”]))
{
$code=str_decrypt($_POST[“安全检查”]);
如果(!(空($code))&&($code=$\u POST['security\u code'])&($password==false))
{
函数验证码\登录\发布($error)
{
返回$error。“错误,安全代码不匹配。请重试。

”; } } 如果(!(空($code))&&($code=$\u POST['security\u code'])&($password==true))则为else { $url=get_site_url()。/wp login.php'; 标题('位置:'。$url); echo“错误,安全代码不匹配。请重试。

”; } 其他的 { $url=get_site_url()。/wp admin'; 标题('位置:'。$url); } }

}

试试看,它不起作用。。我已经试过这个了。。错误来自“可捕获的致命错误:类WP_错误的对象无法转换为字符串”希望这会有所帮助我也使用了这个。。在我的情况下不起作用..我想在登录表单上显示错误..我的'else'情况起作用,它重定向到wp admin..但是'if'部分在验证码代码不匹配时不显示错误消息