Skip to content

Instantly share code, notes, and snippets.

@moxet
Created January 25, 2024 08:28
Show Gist options
  • Save moxet/2002f035159aed4ec167d5f5de37443f to your computer and use it in GitHub Desktop.
Save moxet/2002f035159aed4ec167d5f5de37443f to your computer and use it in GitHub Desktop.
Wordpress Logout without Confirmation
add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
/**
* Allow logout without confirmation
*/
if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
$redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'https://yoursite.com';
$location = str_replace('&', '&', wp_logout_url($redirect_to));
header("Location: $location");
die;
}
}
@bilalshirzad
Copy link

This is very Helpful, really appreciate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment