Author Topic: $context['user']['is_mod'] is not working  (Read 796 times)

0 Members and 1 Guest are viewing this topic.

Offline lexqqq

  • New Member
  • *
  • Posts: 1
  • Karma: 0
  • SMF Version: 1.1.11
$context['user']['is_mod'] is not working
« on: March 09, 2010, 01:35:59 PM »
hello, I am using SMF 1.1.11 and SSI.php file to recognize is user registered or not on my site.
But I have a problem, $context['user']['is_mod'] is not working.

For example if I put code:


:
if($context['user']['is_logged']){
echo 'Welcome ' . $context['user']['name'] . '!!!<br />';

if($context['user']['is_mod']){
echo 'You are moderator!!!';
}
if($context['user']['is_admin']){
echo 'You are admin!!!';
}

} else if($context['user']['is_guest']) {
echo 'Welcome Guest!!!';
} else {
die("dont know what you are so i killed you");
}

everything works fine except $context['user']['is_mod'], which is never active, not even if I am admin, user, global moderator or moderator

please help

Offline butchas

  • Elite Member
  • *
  • Posts: 632
  • Karma: 398
  • Illustrious key typer
    • East Coast Rolling Thunder car club
  • SMF Version: 2.0 RC5
Re: $context['user']['is_mod'] is not working
« Reply #1 on: March 09, 2010, 06:35:02 PM »
Try to call $context in your global statement.
 ???
My mod, My site

Offline ccbtimewiz

  • Dreamer
  • Guru
  • *
  • Posts: 1304
  • Karma: 2100
  • Gender: Male
  • $info->close();
    • Dream Portal
  • SMF Version: SMF 2.0 RC4
Re: $context['user']['is_mod'] is not working
« Reply #2 on: March 10, 2010, 11:55:39 PM »
Use $user_info['groups'] as it returns an array of integers that reflect the groups you're in.

Use in_array() for a singular check, eg in_array(2, $user_info['groups']) which will return true if the user is in group 2.

Use array_intersect for a more complex check (eg checking two arrays together and only returning true if values intersect (match)), eg array_intersect(array(1, 2), $user_info['groups'])