Customizing SMF > SMF Coding Discussion

member group memberships

(1/2) > >>

nightware:
How can I tell  if a the current user is a member af a certain member group?

I have added a new "regular group" on the manage membergroups page, and now I would like to make a button in the menu bar, that is visible to members of that particular group.

Plz help =)

[Unknown]:
You need the id number of that group - for example, 9.

Then, you do this:
$is_in_group = in_array(9, $user_info['groups']);

So, for example:
if (in_array(9, $user_info['groups']))
   echo 'You are special!';

-[Unknown]

nightware:
Thanks, it works perfectly =)

dracomiconia:
Warning: in_array(): Wrong datatype for second argument in **********************/index.template.php on line 454


--- Code: --- // Zona master
if (in_array(22, $user_info['groups']))

--- End code ---

treo:
look what is in your $user_info['groups']:

echo &#39;<pre>&#39;;
print_r($user_info[&#39;groups&#39;]);
echo &#39;</pre>&#39;;

Navigation

[0] Message Index

[#] Next page

Go to full version