Skip to content

Instantly share code, notes, and snippets.

@warengonzaga
Created November 25, 2021 15:10
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 warengonzaga/286e3d6fd1983d7f58c8eb32cb0879be to your computer and use it in GitHub Desktop.
Save warengonzaga/286e3d6fd1983d7f58c8eb32cb0879be to your computer and use it in GitHub Desktop.
WP Snippet - Logout Without Confirmation
<?php
// logout without confirmation
function logout_without_confirmation($action, $result) {
if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
$redirect_to = isset($_REQUEST['redirect_to'])?$_REQUEST['redirect_to']:'';
$location = str_replace('&amp;', '&', wp_logout_url($redirect_to));
header("Location: $location");
die;
}
}
add_action( 'check_admin_referer', 'logout_without_confirmation', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment