Skip to content

Instantly share code, notes, and snippets.

@uptimizt
Created December 18, 2017 09:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uptimizt/7a595e68cd6fe76b3302051014964781 to your computer and use it in GitHub Desktop.
Save uptimizt/7a595e68cd6fe76b3302051014964781 to your computer and use it in GitHub Desktop.
If isset cookie - clear value and redirect to url - WordPress.
<?php
/**
* If isset cookie - clear value and redirect to url
*/
function redirect_after_signin(){
if(is_user_logged_in()){
if( ! empty($_COOKIE["redirect_url_sso"])){
$url = $_COOKIE["redirect_url_sso"];
setcookie("redirect_url_sso", "", time() - 3600);
header('Location: ' . $url, true, 302); // Could also use 301.
// wp_redirect($url);
// exit;
}
}
}
add_action('init','redirect_after_signin');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment