News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

member group memberships

Started by nightware, June 21, 2004, 08:26:56 AM

Previous topic - Next topic

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

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



treo

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

echo '<pre>';
print_r($user_info['groups']);
echo 
'</pre>';

dracomiconia

#5
In this profile:

Array
(
    [0] => 1
    [1] => 4
    [2] => 22
)

dracomiconia

The problem is than if I type:


if (in_array(22, $user_info['groups']))
   echo 'You are special!';


in index.php (home of the portal using SSI)

it types 'You are special'

But if I type (in index.template.php):


if (in_array(22, $user_info['groups']))
echo '
<a href="http://www.dracomiconia.com/nuevaweb/zona_master/">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/masters.gif" alt="' . $txt[103] . '" style="margin: 2px 0;" border="0" />' : $txt[103]), '</a>', $context['menu_separator'];



The output is:


Warning: in_array(): Wrong datatype for second argument in /xxxxxxx/xxxxxxx/xxxxxxxx/nuevaweb/foro/Themes/Dracomiconia/index.template.php on line 454


I have tried if {
} else {
}

clause, too

treo

The output of that what I said above is the same? Btw. your last post keeps crashing my firefox. Could only access it with the wap2 address...

[Unknown]

Quote from: treo on June 27, 2004, 04:26:28 PM
The output of that what I said above is the same? Btw. your last post keeps crashing my firefox. Could only access it with the wap2 address...

Update to Firefox 0.9 if you experience that problem, please.

For the template, use $GLOBALS['user_info']['groups'].

-[Unknown]

Advertisement: