Hi,
I have an issue that all JS codes in my toolset forms and views are not executed suddenly. Before it was working fine.
Could you please help me to figure out this issue?
For Example, This code in the view loop checks the availability of the user and redirects him to the suitable page. it was working but now it shows (No items found )
var myTableArray = [];
jQuery("table#empTable").each(function() {
var arrayOfThisRow = [];
var tableData = jQuery(this).find('td');
if (tableData.length > 0) {
tableData.each(function() { arrayOfThisRow.push(jQuery(this).text()); });
myTableArray.push(arrayOfThisRow);
}
});
var k=myTableArray.toString();
var id =document.querySelector('input[name="wpcf-hidden-id"]').value;
var n = k.includes(id);
if(n == true){
window.location.replace("hidden link..../login");
}
else{
window.location.replace("hidden link.../registration-form");
}
Hello,
It is a custom JS codes problem.
Please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/
2) Check if there is any JS errors in your website, if there is, then try to locate the problem JS codes, and fix them.
Hi Yang,
thank you for your reply.
I have the latest version of Toolset and the latest version of WordPress. everything is updated. and I did patching for the server last week.
How can I check if there are errors in the JS on my website?
hi Yang
there is no error .. only warning.. check the attached image..
Please provide a test site with the same problem, also point out the problem page URLs and where I can edit your custom JS codes, I need to test and debug it in a live website.
Thanks for the details:
1) example of pages with JS
hidden link
Above page is displaying user view "Retrive Users IDs", please check it here:
hidden link
It is querying "Subscriber" users, but in your website, there isn't any "Subscriber" user, see the user list here:
hidden link
So it is expected result, you get the result: No items found
If you want query all users, you can edit the view "Retrive Users IDs", try option "Any role"
2) hidden link
JS in the form: Update User Form
I have tested it in frontend, your custom JS codes work just fine, but I recommend you wrap your custom JS codes with "cred_form_ready" JS event, I have done these:
hidden link
in section "JS editor", edit the JS codes as below:
jQuery(document).on('cred_form_ready', function(){
...
});
Thank you for your reply.
1. It is querying "Subscriber" users, but on your website, there isn't any "Subscriber" user,
So it is expected result, you get the result: No items found
When there is no user the page should redirect me to Create User Page instead of showing 'No Items Found'
2. the JS code already wrapped inside "cred_form_ready".
The JS codes you mentioned above is in user view:
hidden link
I have tried it again:
Open URL:
hidden link
It redirect me to another URL automatically:
hidden link
I don't see the problem you mentioned above:
all JS codes in my toolset forms and views are not executed suddenly
Is there any missing steps?
Thank you Yang,
1. the first issue resolved. It works after I add one subscriber user.
2. But for the second issue, the code still not working properly, the rejection-reason field does not empty after changing the Org although the request status field changed to pending.
So part of the code works and the second part no.
jQuery(document).on('cred_form_ready', function(){
jQuery( 'select[name="wpcf-org"]' ).change(function() {
jQuery( 'b.wpcf-request-status' ).text('Pending');
jQuery( 'input[name="wpcf-request-status"][value=3]' ).prop("checked",true);
});
jQuery( 'select[name="wpcf-org"]' ).change(function() {
jQuery( 'input[name="wpcf-rejection-reason"]' ).val(" ");
});
});
I assume we are talking about the user form "Update User Form"
hidden link
And in the problem page:
hidden link
I don't see above user form.
So I have tried these in your website:
Create a new page:
hidden link
Display the editing user form "Update User Form" shortcode:
[cred_user_form form="update-user-form"]
Test it in front-end:
hidden link
Change option in the dropdown menu "Please Register with other Organization" , it works fine, see my screenshot: pending.JPG
Can you confirm it?
Thank you for your replay Yang,
In the image 1, the status is rejected and the rejection reason is test.
what we expect:
when the user changes the org. the status should be changed from rejected to pending and the rejection reason should be empty.
what we got:
the request status changed to pending but the rejection reason value does not become empty as on image 2.
I have done below modifications in your website:
Edit the user form:
hidden link
in section "Form Editor", change line 33 from:
To:
<b class="wpcf-request-status">
Please test again, check if it is fixed, thanks
I have tried, Unfortunately, still the rejection reason value does not become empty.
It is your custom JS problem, I have setup a demo in your website, edit above user form:
1) In "Form Editor", Change line 43 to:
<b class="wpcf-rejection-reason">[types usermeta='rejection-reason' current_user='true'][/types]</b>
2) change the JS codes lines 8 to:
jQuery( 'b.wpcf-rejection-reason' ).text("");
});