change language by user

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mavel
User
Posts: 88

change language by user

Post by mavel »

hi,

1st step:
I add field on user table: AppLang

2nd step:
Added this code in: Server Events > Global Codes

function AppLanguage() {
    $applang = ExecuteScalar("SELECT AppLang FROM employees");
    return $applang;
}

3th step:
Added this code in: Other > Login Page > User LoggedIn

function User_LoggedIn($usr)
{
    //Log("User Logged In");

    if AppLanguage() == "1") { // french language value 
    $_SESSION[SESSION_LANGUAGE_ID] = "fr-FR";
    }
    else {
    $_SESSION[SESSION_LANGUAGE_ID] = "en-US"; 
    }
}

It doesn't work this way.
I can only change the language on a per-user basis with the CurrentUserID() value. When the user logs into the application, I want him to have the default language that I defined in the user table. I can't find where I went wrong.


mavel
User
Posts: 88

Post by mavel »

I solved.

2nd step:
Added this code in: Server Events > Global Codes

function AppLanguage() {
    $applang = ExecuteScalar("SELECT AppLang FROM employees WHERE EmployeeID =". CurrentUserID() ."");
    return $applang;
}

Post Reply