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/");
}
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/");
}
Share
Improve this question
edited Dec 17, 2019 at 14:37
butlerblog
5,1213 gold badges28 silver badges44 bronze badges
asked Dec 16, 2019 at 18:02
Waqar HussainWaqar Hussain
1
1
- You should do redirects within a hook before content is rendered. Try running that code inside a template_redirect hooked function. – Carlos Faria Commented Dec 16, 2019 at 18:31
1 Answer
Reset to default 1You 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
}