简体   繁体   中英

unable to redirect on wp-admin page

I m facing a problem while implementing my captcha code on the wp-login.php. I want to redirect on wp-admin page of my website when the captcha code maches. Is there a way to redirect on wp-admin page?? my code is :

function captcha_login_check($url) {
    if (isset($_POST["security_check"])) 
    {
        $code = str_decrypt($_POST["security_check"]);
        if (!( $code == $_POST['security_code'] && !empty($code) ))
        {
            wp_clear_auth_cookie();
            return $_SERVER["REQUEST_URI"];
            ?>
            <span style="color:red">
            Error, the Security Code does not match. Please Try Again.
            </span>
            <br>
            <?php
        }
        else
        {
            $url = $_SERVER['HTTP_HOST']."/wp-admin/";
            return $url;
        }
    }
}

Use like

    else
    {
        $url = $_SERVER['HTTP_HOST']."/wp-admin/";
        header('Location:'.$url);
    }

Also You can use this

    else
    {
        $url = $_SERVER['HTTP_HOST']."/wp-admin/";       
        echo ("<script>location.href='$url'</script>");
    }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM