user2746093
user2746093

Reputation: 33

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

Upvotes: 0

Views: 211

Answers (1)

Bindiya Patoliya
Bindiya Patoliya

Reputation: 2764

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

Upvotes: 2

Related Questions