Created
November 25, 2021 15:10
-
-
Save warengonzaga/286e3d6fd1983d7f58c8eb32cb0879be to your computer and use it in GitHub Desktop.
WP Snippet - Logout Without Confirmation
This file contains hidden or 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 | |
// 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('&', '&', 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