Skip to content

Instantly share code, notes, and snippets.

@desenvolvendositeswp
Last active November 21, 2024 14:27
Show Gist options
  • Save desenvolvendositeswp/3fa87fea2a81fcfbca2463951cb167dc to your computer and use it in GitHub Desktop.
Save desenvolvendositeswp/3fa87fea2a81fcfbca2463951cb167dc to your computer and use it in GitHub Desktop.
Fazer logout no Wordpress direto
<?php
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'] : 'inicio';
$location = str_replace('&amp;', '&', wp_logout_url($redirect_to));
header("Location: $location");
die;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment