wordpress登录时显示错误消息

时间:2013-09-06 05:11:41

标签: php wordpress

我想在验证码不正确时在wp-login表单上显示错误消息..我正在使用' login_redirect'和' login_errors'过滤器......我的代码是......

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);
    }
}

}

0 个答案:

没有答案