News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Display a html message to Admins & Moderators only

Started by Wellwisher, August 26, 2016, 04:18:25 AM

Previous topic - Next topic

Wellwisher

Hello SMF developers and community,

Another question: I want moderators & admins only to see a html snippet:

I figured out for admins only to see the html code, I can use:



if($context['user']['is_admin'])




I require admins and moderators to see the message but can't figure out the php, this isn't working:



if($context['user']['is_admin']['is_mod'])




:-[

Shambles


if($context['user']['is_admin'] || $context['user']['is_mod'])
{
}

Wellwisher

Quote from: Shambles on August 26, 2016, 05:23:07 AM

if($context['user']['is_admin'] || $context['user']['is_mod'])
{
}


Hello Shambles, thank you for the reply. I tried this the html shows for admins but not for Global moderators.  ???

Illori

try  if($context['user']['is_admin'] || (in_array(3, $user_info['groups']))

dont forget to add $user_info to your globals.

Shambles

In that case try

if (allowedTo('moderate_forum'))

.. which will cover Admins and Gmods

Illori

Quote from: Shambles on August 26, 2016, 06:11:05 AM
In that case try

if (allowedTo('moderate_forum'))

.. which will cover Admins and Gmods

that is the permission to moderate forum members not moderate boards/topics.

moderate_board might be a better permission to check in this case if it has been granted.

Wellwisher

#6
Quote from: Illori on August 26, 2016, 06:18:13 AM
moderate_board might be a better permission to check in this case if it has been granted.

Thank you @Illori this works like a charm!  ;D ;D ;D I can use this on SP too.  8) Thank you @Shambles for different variations!!

Advertisement: