How do I check for a specific user ID in phpBB2 when executing an IF xor ELSE statement in a php file

StackOverflow https://stackoverflow.com/questions/18670556

  •  28-06-2022
  •  | 
  •  

Question

I have a phpBB2 forum with an integrated package that runs based on PHP files. In one of these files, privileges for who can access a certain page are determined this way:

// only mods and admins will be able to see this control panel.
    if ($userdata['user_level'] < ADMIN)
    //message_die(GENERAL_ERROR,'No permission. If you are looking for the claims browser, it has been integrated into the forums.');
}
else
{
    $mod_privileges = true;
    $template->assign_block_vars("is_auth", array());
    #$template->assign_block_vars("is_auth2", array());
}

And I am looking for a way to add in permission for a specific user on our forum (identified by his account's user ID, we will say 9000 for example) in this PHP file, without giving him access levels of Administrator or Global Moderator access on our phpBB forums.

Would an appropriate change be something like this?

// only mods and admins will be able to see this control panel.
if ($userdata['user_level'] < ADMIN) xor (&phpbb_user_id!==['9000'])
{
    //message_die(GENERAL_ERROR,'No permission. If you are looking for the claims browser, it has been integrated into the forums.');
}
Was it helpful?

Solution

I believe I've figured it out:

if ($userdata['user_id'] != 9000 && $userdata['user_level'] < ADMIN)

This works as intended.

OTHER TIPS

Your condition will be

if ($userdata['user_level'] < ADMIN) || ($phpbb_user_id!=='9000') {

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top