WooCommerce wc_logout_url not working when using redirect url

58
February 11, 2019, at 11:50 AM

I am trying to create a custom logout url using WooCommerce, the below works:

$logout = wc_logout_url();
echo '<a href="' . $logout . '"></a>';

...but when I try and add a redirect URL as below it doesn't seem to redirect and ends up at the actual logout URL such as:

http://example.com/customer-logout/?_wpnonce=dd29939e30

...and shows a "page not found 404" and doesn't even log the user out.

$logout = wc_logout_url(site_url('/'));
echo '<a href="' . $logout . '"></a>';

What am I doing wrong?

Answer 1

I can confirm that this didn't work when including a redirect parameter on a standard WooCommerce install. Try using the WordPress function instead of the WooCommerce function.

wp_logout_url( '/' );
READ ALSO
Automating the numbers of tags in Array of PHP

Automating the numbers of tags in Array of PHP

Each tag word has a number value at the endLike this:

23
What are the image encryption techniques in PHP other than base64? [on hold]

What are the image encryption techniques in PHP other than base64? [on hold]

I want some other techniques to be used to encrypt those images and also how to decrypt and display it on other page

60
How to get resource id on connection establish in ratchet

How to get resource id on connection establish in ratchet

I am using ratchet chat library to create a real-time chat application in PHP CodeIgniterI want to implement one to one chat for which I want to send msg to a particular resource id

21