Retrieve userrank from $userdata ?

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
fjollerik
Registered User
Posts: 5
Joined: Sun Feb 17, 2008 12:31 am

Retrieve userrank from $userdata ?

Post by fjollerik » Mon Mar 17, 2008 10:26 pm

Hi,

I have a login / logout implementation on my site, i can see if there's a new msg and so on from the $userdata but how do i see if the user has a specific rank? Like if the user is an administrator.

Does something like a $userdata['user_rank'] exist ?

Thanks in advance!

User avatar
Lumpy Burgertushie
Registered User
Posts: 66897
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Retrieve userrank from $userdata ?

Post by Lumpy Burgertushie » Tue Mar 18, 2008 3:14 am

rank has no meaning it is simply for show.

the correct variable is:
user_level

to find if someone is an admin :

Code: Select all

if ( $userdata['user_level'] == ADMIN )
or is not admin

Code: Select all

if (! $userdata['user_level'] == ADMIN )
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Re: Retrieve userrank from $userdata ?

Post by drathbun » Tue Mar 18, 2008 7:20 pm

There are two fields to check. One is $userdata['user_level'] which will tell you if the user is an admin or not. Note that admin level is board wide; if a user is an admin, they are an admin everywhere. There is another user_level value for moderators, but it cannot be trusted. A user can be a moderator in one forum and not another. To generate the correct setting for a user being a moderator you should check the "auth" results.

The user rank, which shows the user's rank title (often something like "newbie" or "mega poster" or "spammer" :lol:) is determined by one of two things. There is a field called user_rank that is normally zero, at which point the user's rank is assigned based on their post count. If the user_rank is a non-zero value, then the rank title is retrieved from the phpbb_ranks table. There is some rather complicated logic in viewtopic.php that shows how the rank title is assigned.

Since you're looking for coding tips, I will move your post to the phpBB2 MOD Writers forum for further attention, thanks.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

Post Reply

Return to “[2.0.x] MOD Writers Discussion”