Hi Support
Shane kindly provided us with a custom code snippet "conditional-redirect-on-successful-login". a while back to redirect users based on their role at login.
Everything works as expected in English, but some of the redirects aren't working in German, although we cannot see any issues with page slugs and the pages are translated correctly in WPML. It's not working for roles unverified_nanny or unverified_family.
1) Role unverified_nanny
In EN it redirects successfully to:
$redirect_to = get_site_url() . '/en/become-a-native-nanny-complete-profile'
but in German (DE) it defaults back to the English version instead of going to:
$redirect_to = get_site_url() . '/de/native-nanny-werden-profil-ergaenzen'
2) Role unverified_family
In EN it redirects successfully to:
$redirect_to = get_site_url() . '/en/sign-up-complete-profile'
but in German (DE) it defaults back to the English version instead of going to:
$redirect_to = get_site_url() . '/de/registrieren-profil-ergaenzen'
Thanks and best regards
Simon
Hello,
I assume we are talking about the item "conditional-redirect-on-successful-login" in your website Toolset-> Settings-> Custom code,
There isn't such kind of built-in feature within Toolset plugins, and it is a custom codes problem, according to our support policy, we don't provide custom codes support.
And you did not provide the detail steps to reproduce the same problem, so I am not sure where I can debug this issue.
And it should be very easy to debug the PHP codes, for example, edit item "conditional-redirect-on-successful-login", after line 8, you can output the variable $redirect_to directly:
var_dump($redirect_to);
die();
Then test it with a unverified_nanny user in German page, you should be able to see the result of variable $redirect_to, then you can check if it satisfied those conditions of your custom PHP codes.
Hi Luo
Yes, as stated in my first line, it was the snippet of custom code provided by Toolset "conditional-redirect-on-successful-login".
You are right, my apologies, it was not clear how to reproduce the problem. If you send me a private reply, I can send you two test logins (one for each of the user roles where the redirect is not working) to investigate with. To reproduce the issue you would just have to log in with those test logins. I am not a PHP programmer myself.
Thanks and regards
Simon
Private message box enabled, please provide detail steps to reproduce the same problem.
Hi Luo
You can use the following logins:
1) Role "unverified_nanny"
unverified_nanny@example.com / 123
Log on to hidden link to use the German version
Click "Anmelden" (Log in) in the menu and log in
Should land on page: /de/native-nanny-werden-profil-ergaenzen instead landing on the English version /en/become-a-native-nanny-complete-profile
2) Role "unverified_family"
unverified_family@example.com / 123
Log on to hidden link to use the German version
Click "Anmelden" (Log in) in the menu and log in
Should land on page: /de/registrieren-profil-ergaenzen instead landing on the English version /en/sign-up-complete-profile
If you need any more info, please don't hesitate to contact me.
Thanks and best regards
Simon
I have setup a demo in your website, edit custom codes "conditional-redirect-on-successful-login", line 57~61:
if(str_contains($redirect_to, '/de/')){
$redirect_to = get_site_url() . '/de/native-nanny-werden-profil-ergaenzen';
}else{
$redirect_to = get_site_url() . '/en/become-a-native-nanny-complete-profile';
}
This should work for "unverified_nanny" users, and it only check if it is in German pages.
HI Luo
That worked perfecly! Thanks!
My issue is resolved now.