0

I'm taking over a website that had a user import; it has a function that sets the value for some Boolean fields on the user.

$user->field_perm_connexion['und'][0]['value'] = (int)$permissions['perm_connexion'];
user_save($user);

When I edit the user, the value is correctly checked; when I execute code like the following, the value is wrong.

$user_perm = user_load($uid);
// don't judge the ['und'][0]['value']
if(!empty($user_perm->field_perm_connexion) && $user_perm->field_perm_connexion['und'][0]['value'] == 1){
    $is_allowed = TRUE;
}

I need to go to the user page (in the people menu) and save again, to get the correct values.

What could the problem behind this be?

0

It may be static cache, try:

$user_perm = user_load($uid, TRUE);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.