Jump to content
WebFlake
  • 0

How to check if someone is in a certain secondary group?


Cado

Question

Hello,

I currently want to do a check where if someone is in a certain secondary group then it will change their name on their profile. So far I have something like this.

	{{if $member->member_group_id === 75}}
					<h1 class='ipsType_reset'>            
						{$member->name} example example
                  </h1>
                  {{else}}
                  <h1 class='ipsType_reset'>            
						{$member->name} 
                  </h1>
              {{endif}}

but I believe the {{if $member->member_group_id === 75}} only checks primary groups. is it possible to run a check of an ID of a secondary group.

Thanks,
Cado

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
 {{$secondaryGroups = [];}}
     {{foreach array_filter(explode(',', $comment->author()->mgroup_others)) as $secondaryGroup}}
	     {{$secondaryGroups[] = \IPS\Member\Group::load($secondaryGroup);}}
     {{endforeach}}

{expression="implode(', ', $secondaryGroups)" raw="true"}

 

  • Downvote 1
Link to comment
Share on other sites

  • 0
{{$member = \IPS\Member::load(1);}}
 {{$secondaryGroups = [];}}
     {{foreach array_filter(explode(',', $comment->author()->mgroup_others)) as $secondaryGroup}}
	     {{$secondaryGroups[] = \IPS\Member\Group::load($secondaryGroup);}}
     {{endforeach}}

{expression="implode(', ', $secondaryGroups)" raw="true"}

 

Edited by Hackerr
  • Downvote 1
Link to comment
Share on other sites

  • 0

@Hackerr

So the load(1); is the id, correct?

How do I now add this into my code so it checks the secondary group and then displays name depending on if they are in that group or not?

-

UPDATE: Don't worry I got it working the simple fix was {{if $member->inGroup( array( 75 ) )}}

Edited by Cado
Link to comment
Share on other sites

  • 0
The question(s) in this support topic have been answered and the topic author has resolved their issue. This topic is now closed. If you have other questions, please open a new topic.

Achievements:

February 14 2013 - Joined WebFlake & Became Moderator.
March 26 2013 - Became a Dad of 1 kid.
April 8 2015 - Became a Dad of 2 kids.
July 15 2015 - Retired as a Moderator.
November 11 2016 - Passed my Car Driving Licence.
April 13 2017 - Became apart of the Junior Moderator Team.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...