Skip to content

Instantly share code, notes, and snippets.

@MarceloGlez
Last active November 27, 2022 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarceloGlez/85ede0dee07b22b04491d5054f99afcf to your computer and use it in GitHub Desktop.
Save MarceloGlez/85ede0dee07b22b04491d5054f99afcf to your computer and use it in GitHub Desktop.
Redirección del Logout a la Home en Wordpress
/*REDIRECCION DEL LOGOUT A LA HOME usando youpage.com/wp-login.php?action=logout*/
/**
* Generates custom logout URL
*/
function getLogoutUrl($redirectUrl = ''){
if(!$redirectUrl) $redirectUrl = site_url();
$return = str_replace("&", '&', wp_logout_url($redirectUrl));
return $return;
}
/**
* Bypass logout confirmation on nonce verification failure
*/
function logout_without_confirmation($action, $result){
if(!$result && ($action == 'log-out')){
wp_safe_redirect(getLogoutUrl());
exit();
}
}
add_action( 'check_admin_referer', 'logout_without_confirmation', 1, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment