Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

7 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: February 11, 2016

Hi Koen

Thanks for posting.

I have an idea on how to get this working for you that involves cookies. It's rather advanced though so I want to go over a different idea that's easier to implement.

Basically, the easier idea is to still just have the one /user-login.php page.  But on that page, add a link to each of the other language login pages.  

Does that sound like it would work?

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Hi Ross, thanks for the reply.

I can see what you mean, but it won't work well for me because the user-login.php page has a lot of other content ( that should be in the right language when redirected to...)   

I saw another topic in this forum, maybe I could do something like that also ? : http://www.interactivetools.com/forum/forum-posts.php?postNum=2207991#post2207991 

I don't know much about php so maybe you could direct me in this ? The code I'm thinking of :

On all French website pages:

$language = "french";

In websiteMembership.php:

if($language)=="french"){

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']  = '/fr/user-login.php';

}
else{

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']  = /user-login.php';

}


Does this make any sense at all ;-) ?

Cheers,

Koen

By ross - February 5, 2016 - edited: February 5, 2016

Hi Koen.

I get what you mean with all the other content on the page.

The problem here will be that there isn't enough information for the login page to know what language the current user wants.

What you could do is have a cookie called "language" set on every single page. On all the French pages, set the the language cookie to "French. On all the English pages, set the language cooke to "English". And so forth.

Then, when they get redirected to your login, you can check the cookie.  If the cookie is set to French, redirect to the French login page.

Does that make sense?

Let me know what you think.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Okay Ross,

I'm trying the solution with a cookie, but I'm getting a php error:

Notice: Undefined index: language in /home/ajkdirec/public_html/beheer/plugins/websiteMembership.php on line 14 setPrefixedCookie: Can't set cookie, headers already sent! Output started in /home/ajkdirec/public_html/beheer/plugins/websiteMembership.php line 14

Could you check what I'm doing wrong please ?

My code in the French webpages to set the cookie (at the top):

<?php
setcookie("language", "fr");
?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'beheer/lib/viewer_functions.php';
$dirsToCheck = array('/home/ajkdirec/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

...

My code in websiteMembership.php to read the cookie:

<?php
/*
Plugin Name: Website Membership
Description: Website membership functions for user sign-up, password reminder, login, user specific content, and login only content
Version: 1.10
Requires at least: 2.52
Required System Plugin: True
*/

// UPDATE THESE VALUES

$cookie_var = $_COOKIE['language'];

if ($cookie_var == "fr"){

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/fr/user-login.php';

}
else{

$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/user-login.php';

}

...

Hi Kovali,

It looks like the issue is the language cookie isn't always set, so the $_COOKIE['language'] variable can only be found when setCookie('language', 'fr') is set before the website membership plugin loads. This might fix the issue:

<?php
/*
Plugin Name: Website Membership
Description: Website membership functions for user sign-up, password reminder, login, user specific content, and login only content
Version: 1.10
Requires at least: 2.52
Required System Plugin: True
*/

// UPDATE THESE VALUES

$cookie_var = @$_COOKIE['language'];

if ($cookie_var == "fr"){
  $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/fr/user-login.php';
}else{
  $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'] = '/user-login.php';
}

So the @ symbol tells the code that if there is an error, it should ignore it. In this case that stops an error appearing if it can't find anything set for the $_COOKIE['language'] variable. 

Let me know if you have any questions.

Cheers,

Greg

Greg Thomas
PHP Programmer - interactivetools.com

Seems to work fine now! Thanks !!