Not Solved [How To?] PHP in Template, checking if user is in usergroup per id doesn't work.
#3
Not Solved
(2019-01-09, 07:58 AM)Omar G. Wrote: In which template are you trying to accomplish this? If it is inside some postbit template then $post['usergroup'] and $post['additionalgroups'] are the two variables you need.
<if $post['usergroup'] == 1 || my_strpos(','.$post['additionalgroups'].',', ',1,') then>
foo
</if>

You could also add is_member() to the white list file of functions allowed. Or perhaps it is already there, I don't know.

Hey Omar, thanks for your help, I can't really figure out how I get this to work, because it does not for me. Yes I am using it in the temlpate for postbit (postbit).

This is the code I am trying right now, and also shows what I'm trying to do.

<if $post['usergroup'] != 8 || $post['usergroup'] != 9 || $post['usergroup'] != 10 || $post['usergroup'] != 11 || $post['usergroup'] != 12 || my_strpos(','.$post['additionalgroups'].',', ',8,') || my_strpos(','.$post['additionalgroups'].',', ',9,') || my_strpos(','.$post['additionalgroups'].',', ',10,') || my_strpos(','.$post['additionalgroups'].',', ',11,') || my_strpos(','.$post['additionalgroups'].',', ',12,') then>
// User not in either group, double checked.
<else />

// Output Correct Data
<if $post['usergroup'] == 8 || my_strpos(','.$post['additionalgroups'].',', ',8,') then>
  <span style="text-align: center;margin-top:3px;" class="grouptag grouptag_2" style="background-color:#029ddf;border:0px;">&nbsp; WaterSpoof</span> <br />
</if>

<if $post['usergroup'] == 9 || my_strpos(','.$post['additionalgroups'].',', ',9,') then>
  <span style="text-align: center;margin-top:3px;" class="grouptag grouptag_2" style="background-color:#029ddf;border:0px;">&nbsp; Global</span> <br />
</if>

<if $post['usergroup'] == 10 || my_strpos(','.$post['additionalgroups'].',', ',10,') then>
  <span style="text-align: center;margin-top:3px;" class="grouptag grouptag_2" style="background-color:#029ddf;border:0px;">&nbsp; AFort</span> <br />
</if>

<if $post['usergroup'] == 11 || my_strpos(','.$post['additionalgroups'].',', ',11,') then>
  <span style="text-align: center;margin-top:3px;" class="grouptag grouptag_2" style="background-color:#029ddf;border:0px;">&nbsp; Vengeance</span> <br />
</if>

<if $post['usergroup'] == 12 || my_strpos(','.$post['additionalgroups'].',', ',12,') then>
  <span style="text-align: center;margin-top:3px;" class="grouptag grouptag_2" style="background-color:#029ddf;border:0px;">&nbsp; Cyber</span> <br />
</if>

</if>
Reply


Messages In This Thread
RE: PHP in Template, checking if user is in usergroup per id doesn't work. - by Xazin - 2019-01-09, 09:29 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)