Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created September 15, 2017 19:59
Show Gist options
  • Save lukecav/451275daa51f4fcaf2cbe1eadfa15fe4 to your computer and use it in GitHub Desktop.
Save lukecav/451275daa51f4fcaf2cbe1eadfa15fe4 to your computer and use it in GitHub Desktop.
Bypass logout confirmation in WooCommerce
function wc_bypass_logout_confirmation() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
exit;
}
}
add_action( 'template_redirect', 'wc_bypass_logout_confirmation' );
@knassik
Copy link

knassik commented Apr 17, 2018

This is the only solution that works, thank you very much!

@marlonassuncao
Copy link

Thank you!

@Njengah
Copy link

Njengah commented Jun 13, 2019

@phillipsar
Copy link

I would like to add my thanks, too!

@lukecav
Copy link
Author

lukecav commented Dec 2, 2019

Thanks.

@franyuttii
Copy link

Thanks!

@mqfell
Copy link

mqfell commented May 28, 2023

Works great, thank you!

@ReaganM02
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment