signup with facebook - adding session value

By ht1080z - September 16, 2015

Hi,

I 'am trying to add/transfer to the Facebook Login add-on my $session['language'] value through the login.php/signup/.php by adding the line:

$GLOBALS['WEBSITE_LANGUAGE_FBMAIL'] = strtoupper(@$_SESSION['language']);

and with this global additional data insert user's record.  I have no luck with this.

Can you help me?
Karls

By gregThomas - September 16, 2015

Hey Karls, 

I just want to confirm I understand what you're trying to achieve. So you want the facebook login popup to appear in the language the user has selected to view your site in based on a session variable?

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By ht1080z - September 16, 2015

Hi Greg,

Thank you for your reply.

No, i need to forward the user interface language to the facebook plugin so i can send confirmation email in the current language (multi language feature).

I already done with modification in the membership plugin so i can forward the language selection accordingly.

The facebook login popup is not important if its english by default. (but will be nicer if its change whatever is my language on the login page)

Thank you,
Karls

By gregThomas - September 16, 2015

Hey Karls, 

I understand now, so you're trying to hook into the CMSB language system so you can send sign up emails in the correct language after a user signs up via Facebook. 

The language setting to use is stored in the following global:

  $GLOBALS['SETTINGS']['language'] = 'FR';

The above setting would send the sign up template USER-SIGNUP-FR.

So you could get the appropriate template sent after a facebook sign up using the following code on line 260 of facebookLogin.php:

  $userNum   = mysql_insert(accountsTable(), $columnsToValues, true );
  $localUser = mysql_get(accountsTable(), $userNum );

  // send signup email
  global $GLOBALS;

  $GLOBALS['SETTINGS']['language'] = strtoupper(@$_SESSION['language']);

  list($mailErrors, $fromEmail) = wsm_sendSignupEmail($localUser['num'], $passwordText);
  if ($mailErrors) { die("Mail Error: $mailErrors"); }

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By ht1080z - September 16, 2015

Hi Greg,

Thanks again for your reply.

The Session variable cannot pass in this way to the facebook login add-on, thats way i'am tried with

$GLOBALS['WEBSITE_LANGUAGE_FBMAIL'] = strtoupper(@$_SESSION['language']);

from the login.php/signup.php

Is there any other ways to pass my session variable to the add-on from the front-page (where i use multi-language)?

Karls

By gregThomas - September 17, 2015

Hey Karls, 

I've done some local testing, and it was able to pass the session variable. A couple of things that could stop the variable passing are:

  • The session_start() function is not added before your viewer functions are loaded.
  • The $_SESSION global is not declared in wsm_sendSignupEmail function : 

    // list($mailErrors, $fromEmail) = wsm_sendSignupEmail($userNum, $passwordText);
    // if ($mailErrors) { alert("Mail Error: $mailErrors"); }
    function wsm_sendSignupEmail($userNum, $passwordText) {

      global $_SESSION, $GLOBALS;

      $GLOBALS['SETTINGS']['language'] = strtoupper(@$_SESSION['language']);

If you can't get the session variable to work you can also use the CMSB get/set/delete cookie functions instead of the session to store variables for users.

Cheers,

Greg 

Greg Thomas







PHP Programmer - interactivetools.com

By ht1080z - September 17, 2015

Hi Greg,

After some modification and test, i done with the $session pass to the facebook login add-on.

Thank you for your suggestions!

Karls