Changing language outside of amember

Discussion in 'Troubleshooting' started by juniorm, Nov 18, 2008.

  1. juniorm

    juniorm aMember Pro Customer

    Joined:
    Nov 13, 2005
    Messages:
    47
    Hello,

    I have a website that uses amember and I allow people to see non-protected pages outside of amember in various languages.. (i have an include file for the language they select - like en.inc.php or es.inc.php etc )

    There are a bunch of flags on each page header that a user can click and instantly the page will reload using the correct language file (and store the information of what language in a cookie)

    the problem comes when the user goes to the signup.php page for amember - it defaults to english (or whatever i select in the backend) Is there a way i can just set the cookie variable, or pass a variable?

    the cookie amember uses is: GLOBALS['_LANG_SELECTED']; but it seems to reset this as soon as you go to the signup page.
  2. bentechsoft

    bentechsoft New Member

    Joined:
    Mar 5, 2010
    Messages:
    5
    Any answer?... I stubled on this topic and it is the exactly my problem. I know how to pass the variable through the URL.

    For example : http://www.bentechsoft.com/amember/member.php?lang=fr will open the page in French, http://www.bentechsoft.com/amember/member.php?lang=en will open the page in English.

    This works fine exept when a user tries to access a restricted area (and he's not login in yet)... THe system redirects the user to the login page. But that redirected is takin care of by aMember so I don't have control over the link. I figured that setting GLOBALS['_LANG_SELECTED'] everytime a page opens, would tell aMember which language to use for the login page but it doesn't.

    Doest anybody have an idea how to set the language outside of amember

    Thanks
  3. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    If you are setting the language the viewer uses on your main site and provided the link to the login page in your post is contained within a php page then why not use the variable to either set a $lang variable:
    PHP:
    $language_variable_on your_page=French or English;  // however that is set on your existing site
    if {$language_variable_on your_page=French}$lang=fr
    else $lang=en;


    http://www.bentechsoft.com/amember/member.php?lang=$lang  /will access login form in correct language
    Not knowing actual variable used, nor how it is set, for each language I have used above. But basic idea is to set a language variable to use when calling login script.
  4. bentechsoft

    bentechsoft New Member

    Joined:
    Mar 5, 2010
    Messages:
    5
    Thanks for your answer,

    Unfortunately, it does not solve my problem. Maybe my post was not clear. The two link if provided works fine... The technique works! The problem I have is the following.

    If you click on the following link (which is protected by aMember script) you will get redirected to the login page.

    http://www.bentechsoft.com/clients/index.php

    get you redirected to this link

    http://www.bentechsoft.com/amember/plugins/protect/new_rewrite/login.php?v=-1&url=/clients/index.php

    I have not control over the redirection because it is managed by amember. Therefore, I don't have any control on the language it is displayed. It gets displayed in whatever language is set in the admin CP.

    Is there a way to set the language of aMember programmatically so that the redirection gets done in the language of my choice.

    Thanks
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can use these urls:
    Code:
    http://www.bentechsoft.com/amember/plugins/protect/new_rewrite/login.php?v=-1&url=/clients/index.php&lang=en
    http://www.bentechsoft.com/amember/plugins/protect/new_rewrite/login.php?v=-1&url=/clients/index.php&lang=fr
    
    and give above urls to customers.
  6. bentechsoft

    bentechsoft New Member

    Joined:
    Mar 5, 2010
    Messages:
    5
    Hi All,

    I think I got my answer from the HelpDesk.

    I use the code below in all my pages...

    In all English pages...

    <?php
    session_start();
    $_SESSION[amember_lang] = "en";
    ?>​


    in all French pages
    <?php
    session_start();
    $_SESSION[amember_lang] = "en";
    ?>​


    So far, it seems to work perfectly.

    Thanks

Share This Page