Multiple logi and log out pages

I currently have the membership plugin installed on a site I am working on but this site has two languages so what I need to know is am I able to create different login and logout urls for each language?

ex. if a french user logs in they are redirected to the french section and if a English user logs in through the english section they are redirected to the english section and the same would go for the log out process.

I'm sure it has something to do with copy pasting lines in the membership plugin file but I'm just not sure what exactly. Can someone give me a hand?

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 8, 2010

Hi,

What you need to do is to customize the webisteMembership plugin code where it redirects after login.

In the login function you'll find this code:

// redirect on success
if (@$_SESSION['lastUrl']) { $postLoginUrl = @$_SESSION['lastUrl']; }
else if ($GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']) { $postLoginUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']; }
else { $postLoginUrl = thisPageUrl(); }
$redirectUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'];

unset($_SESSION['lastUrl']);
redirectBrowserToURL("$postLoginUrl");
exit;


You'll need to change this to look for a value in the $CURRENT_USER variable. This variable contains all the fields inside the accounts table.

You can change it to look something like this:
(NOTE: This is only an example. You'll need to customize this to fit your needs and field names)
// redirect on success
if (@$_SESSION['lastUrl']) { $postLoginUrl = @$_SESSION['lastUrl']; }
else if ($GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']) {
if($CURRENT_USER['language']=="french"){
$postLoginUrl="frenchIndex.php";
}
else{
$postLoginUrl="englishIndex.php";
}


}
else { $postLoginUrl = thisPageUrl(); }
$redirectUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'];

unset($_SESSION['lastUrl']);
redirectBrowserToURL("$postLoginUrl");
exit;


Hope this helps get you started.
---------------------------------------------------
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: [Jason] Multiple logi and log out pages

By DanMaitland - November 9, 2010 - edited: November 9, 2010

Thanks J,
Ok so it's a bit different than I thought. I pretty much get what you are doing but what I don't get is the part where you have the word french:

if($CURRENT_USER['language']=="french"){

does this mean that I need to set up the site in a particular way? as it stands right now I have a field for french and a field for english in the admin section. There is no actual French and English section in the admin section.

Is there a way that I can just duplicate the login form and have that form redirect to a different page once submitted? Can I not just add another line in the membership function somewhere like the following:

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/login/login.php'; // url to login form

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/login/login-fr.php'; // url to french login form

$GLOBALS['WEBSITE_LOGIN_SIGNUP_URL'] = '/login/signup.php'; // signup url linked to from the login page

$GLOBALS['WEBSITE_LOGIN_SIGNUP_URL'] = '/login/signup-fr.php'; // signup url linked to from the French login page

$GLOBALS['WEBSITE_LOGIN_REMINDER_URL'] = '/login/reminder.php'; // password reminder url linked to from the login page

$GLOBALS['WEBSITE_LOGIN_REMINDER_URL'] = '/login/reminder-fr.php'; // password reminder url linked to from the French login page

$GLOBALS['WEBSITE_LOGIN_PROFILE_URL'] = '/login/profile.php'; // url to "edit my profile" page

$GLOBALS['WEBSITE_LOGIN_PROFILE_URL'] = '/login/profile-fr.php'; // url to French "edit my profile" page

$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'] = '/clients.php'; // user gets redirected here after login

$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'] = '/clients_fr.php'; // user gets redirected here after French login

$GLOBALS['WEBSITE_LOGIN_POST_LOGOFF_URL'] = '/index.php'; // user gets redirected here after logoff

$GLOBALS['WEBSITE_LOGIN_POST_LOGOFF_URL'] = '/index-fr.php'; // user gets redirected here after french logoff

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 9, 2010

Hi Dan,

In the example I showed you, the script was looking for a field called language in the user's account.

You wouldn't be able to set it up the way you're showing above as each element of the $GLOBALS array can only hold one value. In your example, each one would only hold the french page.

In order to do this, you need to know when a user logs in which type of page they need to go to: English or French. How are you going to tell?

Let me know and I can help you work out a solution.
---------------------------------------------------
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: [Jason] Multiple logi and log out pages

Ok understood but how do does the script know when it's an english page or French. Do I have to label the page somehow?

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 9, 2010

Hi Dan,

What we need to know is when a user logs in, do we need to redirect them to a French or to an English page. So the question is how are we going to distinguish between French and English users? Let me know how you want to make that distinction and we can come up with a script for that.

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: [Jason] Multiple logi and log out pages

I guess that we can create a drop down or checkbox in the admin which specifies french or english.

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 9, 2010

Hi Dan,

Set it up the way you want inside CMS Builder. Then let me know exactly how you did it and I can show you how to change the login script.

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: [Jason] Multiple logi and log out pages

Well like I said before I set it up so that there is an english and a french field in the admin.

ex. title, title_fr, content, content_fr etc...