How to remove logout confirmation message in WordPress

Bypass wordpress are you sure you want to logout screen when logging out of an already logged out account.

/* 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' );

Leave a Reply

Your email address will not be published. Required fields are marked *