XF 2.2 Conditional: thread creator is member of

Old Nick

Well-known member
Hello, i'm trying to set a conditional statement saying if thread creator is member of usegroup_X then...
Can't figure it out since yesterday afternoon ! :eek:

HTML:
<xf:if is="{$thread.user_id} ==  {$xf.visitor.user_id} AND {$thread.user_id}.isMemberOf(3)">
    ...
</xf:if>
❌❌❌
 
I tried this but if i'm not mistaken this code says : if the thread creator is the visitor and the visitor is member of 3 then... but i want to say if the thread creator is member of (3) then...
 
The first part evaluates that the visitor is the thread creator, the second part evaluates if the visitor is in user group 3.

The result will only equate to true if both parts are met.

TLDR; the visitor must be the thread creator and in user group 3.
 
Yes I understand what you are explaining but what I want is when I am on the page of a forum it is to color the discussions which are created by usergroup_1 in blue and those of usergroup_2 in red and that it is visible regardless of the group to which the visitor who is browsing the page belongs and what I have tested and what you are suggesting to me means that the discussions created by usergroup_1 will only be colored in blue if the visitor who is browsing the page is from usergroup_1.
 
This is the key part: {xen:if {$thread.user_post_count}, ' memberPrticipatedThread'} {xen:if '{xen:helper ismemberof, $thread, XXX}', ' staffThreads'} {xen:if '{xen:helper ismemberof, $thread, YYY}', ' VIPThreads'}" .

The evaluation is inline with a CSS class applied.

My resource does something very similar using XF2 syntax: {{ $message.user_id == $xf.visitor.user_id ? 'ctaConversationMessageSelf' : 'ctaConversationMessageOther' }} .
 
I'm back on this...

I wrote this
HTML:
<div class="structItem-cell structItem-cell--icon {{ $thread.user_id.isMemberOf($xf.options.userGroupID1) ? 'border-orange' : '' }}">
Get this
  • Template public:thread_list_macros: [E_USER_WARNING] Cannot call method isMemberOf on a non-object (integer) (src\XF\Template\Templater.php:1177)
So i wrote like this
HTML:
<div class="structItem-cell structItem-cell--icon {{ {$thread.user_id}.isMemberOf($xf.options.userGroupID1) ? 'border-orange' : '' }}">
But i get this
  • Template public:thread_list_macros: [E_USER_WARNING] Function ismemberof is unknown (src\XF\Template\Templater.php:1107)
Any help will be appreciated !
Thanks !
 
Back
Top Bottom