News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

If the user is admin, do this

Started by SaidJan, June 29, 2017, 02:46:33 PM

Previous topic - Next topic

SaidJan

In Display.template.php, I wanna say if the user is admin or anything, do something. How can I do that?
I have this, but it's not working.
if ($context['user']['is_admin'] )

Also when I create a new membergroup, what is the id for that, if I wanna choose the users of only 2 membergroups. should I use "and" or I can put them in 1 if statement?

Arantor

Where exactly did you put that?

Also, the id for the membergroup is the one in the URL when you go to edit the membergroup, but checking if a member is in a group is a bit more complex.

What, exactly are you trying to do? I'm sure there are simpler ways of achieving what you're trying to do with, say, a portal mod.

SaidJan

#2
I gave access to a user to be moderator of only 1 board, and I made a membergroup to put him in that group.
Becasuse I want my users to know where this guy can moderate, so I set a custom title for him. (ex. "Moderator of this board")
Now when he posts, it shows 2 title, one is membergroup called "Moderator" another one is custom title. So I want to remove the groupname if someone has a custom title. (usually my moderators.)

Thanks

Edit: I tried this if ($message['member']['id']==1) and it works for whoever the id number is 1 (admin). Any better way to define the admin? Like is_admin ?
Also I wanted to set it to multiple groups like this: if (!$message['member']['group']==(1 || 2 || 3 || 8 || 9))
which means for above groupmember ids. But not working.

I appreciate your help.

Arantor

If you make him a board moderator, it will replace his usual title with "moderator" in the boards he is a moderator.

Custom title is firmly not the way to do this as it exists everywhere, not just the relevant boards.

SaidJan

I want the users to know where he can moderate when they see a post from a mod.
Looks like this is working:  if (!$message['member']['group_id']==9))
but I want it for 9 and 10. I don't know how to add multiple statements.

Arantor

Sorry, you've lost me in terms of what you're trying to do... are you trying to have something in the post that says "people in this group can moderate boards x, y, z"?

Because that is going to be tough to maintain, likely to become inaccurate and implies you have a very large, untrusted moderation group, and too many boards for the number of posts.

SaidJan

I don't think it's not gonna hard to maintain. Maybe you missunderstood what I'm saying. Would you or someone please tell me the answer to reply #4 ?

Arantor

This is why I'm trying to clarify what you want before I tell you the wrong thing.

Because there are two things you could be trying to achieve, SMF will do one of them for you if you configure it correctly even though you seem intent on not doing that.

Advertisement: