XF 2.1 Checking usergroup id against usergroup ids

Cupara

Well-known member
I have a custom field in the forum table that allows admins to allow usergroups to bypass a restriction in place. Once they choose all the usergroups, it saves to the table in a comma list. What I'm trying to do now is setup the if condition to check the users usergroup and secondary group ids against these saved ids before allowing them to bypass the restriction.

I have this:
HTML:
<xf:if is="{$xf.visitor.user_group_id} == {$node.Forum.gt_ag_grouplist} OR {$xf.visitor.secondary_group_ids} == {$node.Forum.gt_ag_grouplist}">

It doesn't seem to work as the restriction bypass does not allow me to pass so I'm assuming the method I am using of '==' is not going to work but I'm not sure what else to use that will work in this case. I'm extending the forum and node classes so rewriting code that already exists honestly is not a road I want to take.
 
I guess the best way to put this is I need something similar to using the SQL operator 'LIKE' but whatever I would need to use in a template that would mean the same thing.
 

Though I'd say your approach might be wrong anyway. Node permissions should be node permissions and not forum settings
 
Thanks @Kirby I remember seeing that post awhile back but forgot about it. I got what I needed, now to make it work right since I'm using
HTML:
<xf:if is="!{$extras.privateInfo} OR !{$node.Forum.gt_ag_agegate} AND {$xf.visitor.Profile.getAge(true)} >= {$node.Forum.gt_ag_agelimit} OR {{$xf.visitor.isMemberOf([{$node.Forum.gt_ag_grouplist}])}}">
and it still shows Private so I'm not sure if I need to move things around.

To add to that, if I just have the var displayed, it shows Array instead of 3, 4
 
Last edited:
Back
Top Bottom