An ajax form is not working with ajax and the page is refreshing on validate and on submit.
Here is the staging url. hidden link
The form appears if u click login at the top bar and then change the tab to register.
Hi,
Thank you for contacting us and I'd be happy to assist.
Do you see any error or warning in the browser's console or in the server's error logs, when the page refreshes?
( ref: https://wordpress.org/documentation/article/debugging-in-wordpress/ )
Also, is this happening only when the form is used inside the popup/modal? I see the same form is also used without a popup/modal on the "Register" page.
regards,
Waqar
On the register page the forms work normally.
I was geting some errors in the console i manage to fix them but the form still refreshing the page. I will check and the server logs.
Thanks for the update and I'll wait to hear back about the error logs.
I didnt found anything related to that pop up form in the server logs. I also added the form to a test page in the live website and the same issue there.
I couldn't reproduce this issue on my test website.
This suggests that something specific to your website is involved. Can you please share temporary admin login details, in reply to this message?
I'll also need your permission to download a clone/snapshot of the website, in case it needs to be investigated on a different server.
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
Thank you for waiting, as we had a busier-than-usual forum queue, after the weekend.
I tried to log in to the admin area, but it is showing the incorrect username/password message.
Can you please test the username and password again? I'm setting your next reply as private.
Thank you for sharing the updated access details.
I was able to access the website's admin area and see that it is on a multisite network. I didn't have access to view the list of active plugins because of the user level.
This does seem like a compatibility issue with a third-party plugin or a server configuration because a user form with the exact same settings and fields works as expected on my test website.
I'll need to download a clone/snapshot of this website and investigate this on my test server to narrow down the conflict. Can you please elevate this user's role to 'super admin'?
Hey, I have give you a super admin access.
Please note that the current site its a test site and you can do your tests their as well as we are wasting a lot of time with that.
Thank you for waiting, as I worked on this complex troubleshooting.
This website's setup is quite challenging, as many third-party plugins and custom code are involved.
On your website's clone, I was able to make the user register form work with AJAX, from inside the popup/modal window, through the following code:
function hidden_user_form_function() {
if ( !(is_user_logged_in()) ) {
ob_start(); ?>
<div style="display: none;" class='hidden-user-form'><?php echo do_shortcode('[cred_user_form form="Register Form"]'); ?></div>
<script>
jQuery(document).ready(function( $ ) {
$('input[type="password"][name="user_pass"]').change(function() {
$('.hidden-user-form input[type="password"][name="user_pass"]').val($(this).val());
});
$('input[type="password"][name="user_pass2"]').change(function() {
$('.hidden-user-form input[type="password"][name="user_pass2"]').val($(this).val());
});
});
</script>
<?php echo ob_get_clean();
}
}
add_action( 'wp_footer', 'hidden_user_form_function' );
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
This custom code includes a hidden instance of the user form 'Register Form', in the footer, when the visitor is not logged in. The script part ensures that what is entered in the password fields of the form in the modal/popup, is also copied into the respective password fields of this hidden form.
( or else the form won't submit due to a password mismatch error)
In the presence of this second instance of the form, which is not inside a popup/modal window, the form's script to submit it through AJAX is fired correctly.
thanks I will check it and come back to you
Sure please take your time and let me know how it goes.
thanks, working fine with your solution