Multiple logi and log out pages
19 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: November 16, 2010 (RSS)
By DanMaitland - November 9, 2010 - edited: November 10, 2010
Re: [Dan Maitland] Multiple logi and log out pages
By Jason - November 10, 2010
In the example below it checks to see what the value of the language field is for the $CURRENT_USER and sets a redirect url.
NOTE: you may need to change some variable names to match what you have in the database.
// redirect on success
if (@$_SESSION['lastUrl']) { $postLoginUrl = @$_SESSION['lastUrl']; }
else if ($GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']) {
if($CURRENT_USER['language']=="french"){
$postLoginUrl="/login/login-fr.php";
}
else{
$postLoginUrl="/login/login.php";
}
}
else { $postLoginUrl = thisPageUrl(); }
$redirectUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'];
unset($_SESSION['lastUrl']);
redirectBrowserToURL("$postLoginUrl");
exit;
This code should take care of redirecting after login. It won't take care of redirects to the profile page, logging off, etc.
Making a site bilingual can be a very complicated processes. If you require more help on this, I would suggest sending an email to consulting@interactivetools.com and we can help tailor this code directly to your needs.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
In that last piece of code you put up, is $postloginUrl="/login/login-fr" the page that the user will be redirected to once they have logged in? and couldn't this same piece of code work for the logout process?
Re: [Dan Maitland] Multiple logi and log out pages
By Chris - November 11, 2010
Yes, you can use the same approach for the "redirect after logoff" logic. Change your _websiteLogin_logoff function to the following: (changes in red)
// remove login cookies
function _websiteLogin_logoff() {
global $CURRENT_USER;
// remove login cookies
$_SESSION = array();
session_destroy();
// redirect after logoff
if($CURRENT_USER['language']=="french"){
$logoffUrl="/index-fr.php";
}
else{
$logoffUrl="/index.php";
}
// unset current user
$CURRENT_USER = false;
//
redirectBrowserToURL($logoffUrl);
exit;
}
The PROFILE_URL isn't used anywhere inside the Website Membership add-on, it's simply there for organization. When you add a link to a profile page, you'll want to use an IF to decide what the URL should be:
<a href="<?php
if($CURRENT_USER['language']=="french"){
echo "/profile_fr.php";
}
else {
echo "/profile.php";
}
?>">Edit Profile</a>
And you're done!
The LOGIN_FORM_URL, SIGNUP_URL, and REMINDER_URL aren't meant to be used for users who are already logged in — when you don't have a user logged in, you won't be able to use the current user's language field to decide what language to show the user, so you'll probably want to use regular links to let users choose their language.
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Multiple logi and log out pages
Re: [Dan Maitland] Multiple logi and log out pages
By Jason - November 12, 2010
Does the login work correctly or does it always redirect to the English page as well? If you want to fill out a second level support request here:
https://www.interactivetools.com/support/email_support_form.php
I can take a quick look and see what's going on.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Dan Maitland] Multiple logi and log out pages
By Jason - November 12, 2010
I would suggest filling out a 2nd Level Support Request here:
https://www.interactivetools.com/support/email_support_form.php
and we can take a closer look at this.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Dan Maitland] Multiple logi and log out pages
By Jason - November 16, 2010
I found the problem. What was happening in the logoff function is that this code:
// unset current user
$CURRENT_USER = false;
was appearing both before AND after your if statement. This code destroys the $CURRENT_USER variable which is being used in the if statement. This is why is was always redirecting you to the English page. I removed it so that it only appears after the if statement and is seems to work fine now.
Hope this helps.
Jason
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/