Skip Navigation

[Resolved] Toolset forms (CRED & login) issues when using WPML

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user is encountering 3 issues, with WPML, for a user form when edited while the admin language is set to a secondary language.

The admin language is set by a cookie. This can happen in two cases:

  • Switch to the secondary language, then edit the form from Toolset->User Forms->Edit form.
  • Switch to the secondary language in the latest opened browser tab.

The user has a user form that is meant to redirect to a page. The user was encountering the following issues:

  • The repeat password label was displayed translated on the primary language
  • The pages to redirect to appears on the second language.
  • The redirects takes the user to the homepage.

Solution:
Toolset forms are not translated manually. They are translated using WPML through the WPML translation management workflow.

Toolset enforces a form to be created on the primary language. But, it does not enforce this while editing a form.

This will be addressed in a future update. As a workaround add the following code to your a Toolset custom code snippet:

add_action( 'current_screen', 'ts_enforce_form_language' );
function ts_enforce_form_language( $screen ){
    if ( in_array( $screen->id, array( 'cred-form', 'cred-user-form' ) ) ){
        $default = apply_filters( 'wpml_default_language', NULL );
        $current = apply_filters( 'wpml_current_language', NULL );
 
        if ( $default != $current ){
            do_action( 'wpml_switch_language', $default );
        }
    }
}
This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 7.46 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 28 replies, has 2 voices.

Last updated by caroleM-4 3 years ago.

Assisted by: Jamal.

Author
Posts
#2210505

Hello,

I am actually trying to set a registration form (CRED) and a login template to display to not logged-in users when they are trying to access pages of a post group defined in Toolset Access.

Unfortunately in both cases I encounter issues that seem to be related to WPML :

1) CRED forms are defined as default language content but their edit mode opens in last used language, this even if "Set admin language as editing language." is enabled. If saving the form when editing it in a secondary language, the reset password label will display in this language and the page selected to redirect to after submission will be lost.

2) [wpv-login-form] does not display (all languages) if added to the message to be displayed after CRED form submission, this even if the form is edited in default language when adding the shortcode and then translated.

2) [wpv-login-form] displays correctly if directly added to pages in default or secondary language (via a shortcode block or text and field block) or if added to a content template which is then added to the pages but, if the content template is set to be used in replacement of the content of pages included in a post group defined in Toolset Access for a role that does not have read access (guest in this case) to it, it does not display on secondary language pages, this no matter if the template has been translated or not. I also tried to define one group for each language in order to assign the default language template to default language pages and the translation to secondary language pages but it does not work better.

Is there a way to get all that working correctly on a WPML website or at least a workaround I could use ?

Thanks in advance for your help and have a nice day.

#2210847

Hello and thank you for contacting Toolset support.

Sorry, but I am not sure to understand the issue with the Toolset form. Would you like to reproduce it on my test site? Or provide detailed steps to follow to reproduce it?

Regarding the [wpv-login-form] issue, I tested it on a clean install and I was not able to reproduce the issue. You can check it here hidden link
These are the steps that I followed:
- Made my user translator in WPML->Translation Management.
- Made Pages managed by Toolset Access in Toolset->Access Control.
- Created a content template that has the [wpv-login-form] shortcode.
- Created a page to be restricted.
- Created a Post group for logged-in users. And configured it to display the content template for guest users.
- Translated the page and the content template.
=> At this stage, everything works as expected. You can check the restricted page in a private browsing window in both languages:
- hidden link
- hidden link

Would you allow me temporary access to your website to check it closely? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

Please provide more details so I can check both issues.

#2211795

Thank you for this test site. I wonder if I can take a copy of it?

I could not spot the difference between this site and my test site, everything seems similar. I tried with a new page and only add the original page to the posts group, but did not help. Adding its translation to the posts group does not help too. So, I'll need to perform more debugging in my local setup, and eventually escalate the site's copy to our 2nd Tier if I could not fix it.

#2211801

Thanks for the feedback Jamal. Of course you can take a copy, no problem for me.

#2212689

I built the copy on my local environment and the issue was not reproduced with the restricted page. The login form appears on both languages. I added another translated page(Sample page) to the post group and it worked for it on both pages too.

I compared both environment and you are currently using PHP8 which is not yet supported by Toolset. https://toolset.com/toolset-requirements
Can you downgrade to PHP 7.x and let me check again?

#2212987

Sorry I did not think Toolset was not ready for PHP 8 as end of active support for version 7.4 is planned for November 28th.

I downgraded the sandbox to PHP 7.4 but it does not seem to be better, this no matter if both pages are added to the group or only the original one.

In fact, Access does not even prevent the content to be displayed to guest even though the group is set to do so.

I tried to add another group with the two sample pages in it but without setting a content template and the same is happening, the FR page displays normally : hidden link. So, it seems the problem comes more from Access than from the login form shortcode.

Hope you will find what's going wrong because I really need to be able to protect pages in both languages.

#2215117

I migrated your website to our online platform to this address hidden link
The issue is reproduced on our server too.

Let me approach our 2nd Tier team for further assistance and get back to you.

#2215535

Thanks for the update Jamal, I am glad to hear you could reproduce it because I was worrying about what I was going to do if not.

While waiting for a fix to be found, I was wondering if I could eventually use conditional blocks to replace access functionalities on the pages I need to protect and then maybe leave it as a sort of "two steps protection" for the case I encounter a similar problem in the future.

Do you think it would be safe to rely on a "NOT ( empty( '[wpv-current-user info="id"]') )" condition to hide contents of the page to not logged in user and just place the login shortcode outside of the conditionnal block for users to be able to log in ?

And would that also work in combination with the access page groups / error template functionalities once they will be working normally or using both methods together could leave to unexpected behavior ?

#2218427

Hello and my apologies for the late reply. While waiting for our 2nd Tier team analysis, I totally missed your last message. My apologies for that.

Our 2nd Tier team find out that this issue appears when using WPML with languages in URL parameters, if you configure languages to use different directories, the issue will not be reproduced, and that's what happened in my test site. Check this screenshot from WPML->Languages hidden link

The issue is now escalated to the developers, and I'll let you know as soon as we have something to share about it.

In the meantime, I would like to know if switching WPML URL format is a viable solution?

#2219377

Thanks for the feedback Jamal. I confirm that using WPML setting "Different languages in directories" does solve the post group / login shortcode issue and that it may be a viable solution for me even if it will need a solid redirection setup as the website has been running for a few years using "Language name added as a parameter".

Unfortunately it does not solve the two other issues mentioned in my first post :

1) CRED forms are defined as default language content but their edit mode opens in last used language, this even if "Set admin language as editing language." is enabled. If saving the form when editing it in a secondary language, the reset password label will display in this language and the page selected to redirect to after submission will be lost.

2) [wpv-login-form] does not display (all languages) if added to the message to be displayed after CRED form submission, this even if the form is edited in default language when adding the shortcode and then translated.

Is there a way to get that working too and could you please also tell me what are Toolset plans regarding PHP 8 compatibility ?

Thanks in advance for your help and have a nice weekend.

#2220413

Regarding PHP8, we have some ongoing efforts to make all Toolset plugins compatible, but we do not have an estimated date of when this would be released.

I wanted to check this again on the migrated site, but it has been deleted after we come up with the last conclusion. So, I hoped if you can give me the steps to follow to see issue 1, because honestly, I was not able to reproduce it on my previous tests. Can you tell what to do in details to see it? Something like:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead i get xxx

#2221207

The path to follow is :
1) Create a cred user form with a redirection on submit and a password field (already have one on hidden link)
2) Either set your account to a secondary language or check "Set admin language as editing language." and edit a content of a secondary language
3) Edit the user form again, change the page to redirect on submission and save.
4) The label of the password confirmation field of the form is now displaying in the secondary language you used while saving it
5) If you now edit the form again while your admin language is the default one, you won't see the page to redirect on submission appear on the dedicated field.

This is annoying as standard users won't easily understand they have to double check their editing language while editing forms and switch to default one if needed. If editing language may cause issues when saving a form, I guess it should be switched to default when opening form edit mode as those are meant to be edited only in the default language.

As for the password confirmation field label, I think it should be either a setting of the password field or included in the string we can set for the form so we can choose it and translate it the way we want as any other form element.

Do not hesitate to tell me if you need anything else and have a nice day.

#2222193

Thank you for the details. I was able to reproduce this issue on a clean install. In fact, when you edit content on the secondary language, then directly edit and save the form, it gets saved as if it was created on the secondary language, and the "Repeat password" label displays in the secondary language when we open the form on the primary language.

We can consider this a bug. But, we do have a workaround to fix it. Go to WPML->String Translation. Search for the label(in the secondary language). You will find it registered in the primary language. Select the string, then change its source language using the dropdown at the bottom of the strings table. Then translate it to the primary language.

However, we cannot consider that the form gets saved on the secondary language as a bug. Because we do allow to create forms in any language, not only the primary language. Consider a use case where you would like to have different forms across languages than having the same form translated. Or consider a use case where we want a form only on the secondary language.

I do agree, that it may be frustrating or confusing to switch languages before starting to edit the form. But that's how WPML works. You will have to make sure that you are on the primary language if you want to edit a form.

From a WPML perspective, we do encourage to use the translator editors, that way, no one will need to switch to the secondary language at all. But, if you need to translate some content manually, or you need to have some content on secondary languages, then you will have to switch to the primary language before starting to edit a Toolset form.

Regarding your suggestion to make the repeat password label customizable through a setting, I'll have to ask you to suggest it here, so our product manager can evaluate it and schedule it on an upcoming version https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

I hope this answers your questions, and gives you more insights on how Toolset Forms and WPML can work together. Let me know if you have any further questions.

#2222331
2.jpg
1.jpg

I would agree with your explanation if it was really possible to add a form in any language like it's possible for normal translatable content (pages for example) but that's absolutely not the case.

As you will see in attached screenshot 1, forms created in secondary language also have default language as source and are thus only translatable in secondary languages.

In fact all forms are saved as default language contents and thus have to be translated in secondary languages via translation editor. There is no other choice and that's fine for me but all their elements should then also be considered as default language ones no matter in which language we do edit them or at least admin language should automatically switch to default when editing them which is not the case either, no matter if "Set admin language as editing language." is checked or not.

As for avoiding to edit them when using a secondary language it's not really easy as there is no language switcher and no language column on the list page (screenshot 2) which means we have to use other elements (toolbar, menu, etc.) to check for the language and if not good go to another page to change it and come back to edit the form.

Any standard user will get lost in such a mess so, honestly, that part of Toolset / WPML integration could really be improved.

#2222437

I run a test on a clean install, and based on your tests, I would agree that the forms are all saved in the default language. However, I could not reproduce this issue on this test site. hidden link

Either if I enable the "Set admin language as editing language." or not, editing content on the secondary language, then saving the form does not produce any unexpected results. The repeat password label is displayed correctly on each language. You can check it here:
- English: hidden link
- Spanish: hidden link

Let me migrate your sandbox site to our platform again, and conduct some debugging. I'll try to find a workaround for this "Repeat password" label issue. Please let me know if this "behavior"(Editing in secondary language, then saving the form) unexpected results somewhere else?