Forked from firefly05/Skip Wordpress confirmation screen on logout
Last active
August 29, 2015 14:11
-
-
Save adis-io/20a924a6c5eab116ac28 to your computer and use it in GitHub Desktop.
This file contains 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
// originally by Camden Ross. Thanks | |
/* bypass wordpress are you sure you want to logout screen when logging out of an already logged out account. */ | |
function smart_logout() { | |
if (!is_user_logged_in()) { | |
$smart_redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '/'; | |
wp_safe_redirect( $smart_redirect_to ); | |
exit(); | |
} else { | |
check_admin_referer('log-out'); | |
wp_logout(); | |
$smart_redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '/'; | |
wp_safe_redirect( $smart_redirect_to ); | |
exit(); | |
} | |
} | |
add_action ( 'login_form_logout' , 'smart_logout' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment