Plugin Woocommerce direct logout

WooCommerce request to click on a confirmation link once click “logout”.
There are two ways to bypass and remove the “Are you sure you want to log out?” link.

Via Plugin

I made a small plugin called Direct Logout.
This plugin bypasses the WooCommerce logout confirmation link and lets you choose where to redirect the now logged-out user.
You can decide to redirect to the homepage, a custom page, the login page, or the same page
You can download the plugin by searching Direct Logout in the WordPress plugin directory

Note: Always backup your site before installing any plugin

Download plugin for bypasses the WooCommerce logout confirmation link

Via Hooks (experts)

The plugin is an easy way to bypass the logout confirmation link, but we must admit that is an overkill approach.
If you know what are you doing you can simply put this following Hook in your function.php page (in the child theme).
After the logout, it will redirect to the login page.

function direct_logout() {

    global $wp;
    if ( isset( $wp->query_vars['customer-logout'] ) ) {

		wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
		header("Refresh:0");
        exit;

    }

}
add_action( 'template_redirect', 'direct_logout' );

Resources

There are several blog post where you can find many approach and tips to how to bypass the WooCommerce confirmation link on logout here a list of what I found:

https://iconicwp.com/blog/bypass-are-you-sure-you-want-to-log-out-message-in-woocommerce/
https://njengah.com/woocommerce-logout-without-confirmation/
https://gist.github.com/lukecav/451275daa51f4fcaf2cbe1eadfa15fe4


Questions? Suggestions? Please leave a comment below.
I've really saved your ass? Buy me a beer

Leave a Reply

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

*