Login redirect based on user language

12 years 2 months ago #191011 by adop
I am trying to setup a login redirect auto action based on user language param. On the basis of some of your tutorials this is what I managed to put together but still falling short of my objective:

Trigger: onAfterLogin
User: Automatic
ACL: Everybody
Condition: -
Method: PHP (eval)

and this is the code:
Global $_CB_framework;
 
$myId		=	$_CB_framework->myId();
$cbUser		=&	CBuser::getInstance( $myId );
 
if ( ! $cbUser ) {
	$cbUser	=&	CBuser::getInstance( null );
}
 
$user		=&	$cbUser->getUserData();

$lang_tag = $user->params('language');

switch ($lang_tag) {
	case 'en-EN':
		$login = 'index.php?option=com_comprofiler&Itemid=347&lang=en';
		break;
	case 'es-ES':
		$login = 'index.php?option=com_comprofiler&Itemid=350&lang=es';
		break;
	default:
}

%login is the variable that I see in the cb login module and storing the login redirect url.

Could you take a look at the code and tell me where I am wrong?

Thanks,

adop

J2.5.3 CB 1.8.0 GJ 2.5.1 Kunena 1.7.2

Please Log in to join the conversation.

12 years 2 months ago #191019 by krileon
Replied by krileon on topic Re: Login redirect based on user language
You should be able to accomplish this with a Redirect action using conditionals. Please try the below.

Action 1
Type: Redirect
Trigger: onAfterLogin
User: Automatic
Access: Everybody
Condition: [cb:config param="lang_tag" /] Equal To en-GB
URL: index.php?option=com_comprofiler&Itemid=347&lang=en

Action 2
Type: Redirect
Trigger: onAfterLogin
User: Automatic
Access: Everybody
Condition: [cb:config param="lang_tag" /] Equal To es-ES
URL: index.php?option=com_comprofiler&Itemid=350&lang=es


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.291 seconds

Facebook Twitter LinkedIn