Submit the WooCommerce login form via Ajax

I've registered users on my site and require them to reset their passwords before logging in. I've added a user meta field to check if they've already changed their password. If they have, they can log in as usual; if not, they see a pop-up prompting them to reset their password. The pop-up appears correctly, but when users who have already changed their password submit the form via AJAX, the form is submitted, but they aren't logged in. I suspect it might be a security issue, but I'm not sure how to resolve it. `;(function($){ $(document).ready(function(){ $('form.woocommerce-form.woocommerce-form-login').on('submit', function(e) { var form = $(this); e.preventDefault(); // Prevent the form from submitting by default var username = $('#username').val(); var password = $('#password').val(); // Check if the user needs to reset the password $.ajax({ url: passwordResetData.ajax_url, type: 'POST', dataType: 'json', data: { action: 'check_is_pass_changed_status', username: username, password: password, form_data: form.serialize() // Serialize the form data }, success: function(response) { if (response.success && response.data.show_popup) { $('#password-reset-modal').fadeIn(); } else if (response.success) { form.submit(); // Submit the form programmatically } else { console.log("Error: " + (response.data.message || 'Unknown error.')); } }, error: function(xhr, status, error) { console.error('AJAX Error:', status, error); } }); }); }); })(jQuery);` When i am submiting the form, user should login.

Comment (0)

You’ll be in good company