0

Sometimes the woocommerce login form is not working on the first try, but it is working on the second one. There are no error messages, the POST contains all the necesarry information, and I made sure that the submitted information is correct, yet the page gets reloaded without logging in the user (no error in the logs). On the second try, it works perfectly. I have tried debugging it, by following the user login process, that can be found here. Unfortunately I am having a very hard time with this simple issue. I have inserted a die(), in the wp_authenticate action, but on the first try, it seems that this action isn't even called. What should I check to find the problem?

  • I have found the problem, in the woocommerce plugin, there is a function called "process_login()" , and in that function: wp_verify_nonce( $nonce_value, 'woocommerce-login' ) returns false on the first try... One step closer to the solution – t_csba Oct 14 at 21:55
0

I have solved the issue. If you are having a strange validation problem that ONLY happens when you first load a page, and you have Woocommerce running on this particular site it might help you too.

Solution to my specific problem:

 /**
 * WooCommerce login not working on first try fix
 */
add_filter('nonce_user_logged_out', function($uid, $action) {
  if ($uid && $uid != 0 && $action && $action == 'woocommerce-login') {
     $uid = 0;
  }
   return $uid;
}, 100, 2);

More info about this issue here and here.

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.