Created
March 29, 2018 17:55
-
-
Save joshcanhelp/e3eb693749f0fe66aad097c3bbb3b415 to your computer and use it in GitHub Desktop.
Append a cache-breaking parameter to login_url redirects
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
/** | |
* Append a cache-breaking parameter to login_url redirects | |
* | |
* @param string $login_url | |
* @param string $redirect | |
* | |
* @return string | |
*/ | |
function wp_auth0_gist_cache_break_redirect_to( $login_url, $redirect ) { | |
if ( ! empty( $redirect ) ) { | |
$login_url = remove_query_arg( 'redirect_to', $login_url ); | |
$redirect = add_query_arg( 'logged_in', 1, $redirect ); | |
$redirect = urlencode( $redirect ); | |
$login_url = add_query_arg( 'redirect_to', $redirect, $login_url ); | |
} | |
return $login_url; | |
} | |
add_filter( 'login_url', 'wp_auth0_gist_cache_break_redirect_to', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment