Redirect to Current Page for WooCommerce Logout

时间:2018-12-03 12:50:55

标签: function redirect woocommerce logout

I went through all possible solutions given here to add a function to be able to redirect the user during logging out to the current page, but it's not working.

Via the backend appearance > menu I added the WooCommerce logout link in the header, which generates a button with href="example/my-account/customer-logout/?_wpnonce=9de5663980". What I'd like to see, is that the customer is not being redirected to /my-account, but to the current page.

I have tried many different attempts to get this resolved, but unfortunate, here's one:

function custom_login(){
    global $pagenow;
    if( 'wp-login.php' == $pagenow  && ($_GET['action']!="logout") && is_user_logged_in() ) {
        wp_redirect( get_page_link() );
        exit();
    } 
}

0 个答案:

没有答案