0

I am using woo-commerce. The logout URL is different which includes 'customer-logout'. In reality it again redirects to 'wp-login.php' to make logout process successful. My question is, when Woo-commerce doesn't call 'wp-login.php' for Logging in, and why does it call for logging out? I know, this has been asked several times since at-least 5 years, but there is no direct answer. I am using htaccess password lock for admin area. With this any new/existing customers can register and login without any issues. But, while the customer logs out, since the wp-login.php is called, it asks for htaccess username and password. This implies for all types of users, admins, non-admins too.

Is there a way to Logout Customers without calling wp-login.php?

Edit: I have used logout redirect function too, to redirect customers to custom page after they click on logout. This doesn't work either for me. No matter wp-login.php is called. PS: Technically, customer logout url is different. It too redirects to wp-login.php

4
  • if your .htaccess password lock is correctly set for just the admin area, then it wouldn't be triggered on your wp-login.php since this isn't in the wp-admin folder. Perhaps it's worth reviewing your .htaccess "password lock". – Paul G. Jun 9 at 10:34
  • Thanks again Paul for reply. This code doesn't work either in my case. If I password lock my wp-admin folder, of course, it asks the ht username and password. By entering that, I am able to access login page. BUT, if the I directly go my login page, i.e, domain.com/wp-login.php, it doesn't work. I mean, anybody will be able to directly access my login page with password. – baazigar Jun 10 at 11:58
  • I would assume that your exact problem is not that users can not log out without wp-login.php page, but that they are redirected to it after they have been logged out, and what you realy want is for them to be redirected to some other page. If I am correct please edit the question to reflect it. – Mark Kaplun Jun 10 at 12:17
  • Question Edited – baazigar Jun 10 at 12:43
0

I have found a work around for this problem by utilizing Cloudflare Firewall rules. 5 are Free. I used just 2. It works perfectly. Any inputs will be appreciated. What I did is,

  • 1

Blocked direct access to /wp-login.php if it doesn't contain /wp-login.php?action=logout. So, a customer can easily logout without calling for wp-login.php. No Error.

So now, How do I login?

  • 2

Create another rule to allow access to /wp-login.php only if a cookie is found in the browser. Here, if I want to login, First, I will open my site. Then add a custom predefined cookie. And then access my /wp-login.php. Simple! That cookie name and value is my key to gain access to login page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.