Created
December 18, 2017 09:31
-
-
Save uptimizt/7a595e68cd6fe76b3302051014964781 to your computer and use it in GitHub Desktop.
If isset cookie - clear value and redirect to url - WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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