0

Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\wordpress\wp-includes\formatting.php:5688) in D:\xampp\htdocs\wordpress\wp-includes\pluggable.php on line 961

I am using this function

if(isset($_GET['logout']))
{
    //echo "test";
    //die();
    wp_logout();
    wp_redirect("http://localhost:2124/wordpress/game/");
    exit;
    //wp_logout_url("http://localhost:2124/wordpress/logout_custom");
    //exit();
    //die();
    //wp_redirect(site_url().'/login');
    //return "<script> location.replace('".site_url()."/login');</script>"; 
    //exit();
    //wp_redirect(site_url()."/login/");
}
1
  • You should do redirects within a hook before content is rendered. Try running that code inside a template_redirect hooked function. – Carlos Faria Dec 16 '19 at 18:31
1

You should do redirects within a hook before content is rendered. Try running that code inside a template_redirect hooked function.

Something like this:

add_action( 'template_redirect', 'my_redirects', 5 );
function my_redirects(){
    // Your code here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.