1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 xen:helper ismemberof

Discussion in 'XenForo Questions and Support' started by RichardKYA, May 19, 2015.

  1. RichardKYA

    RichardKYA Well-Known Member

    Hello,

    "xen:helper ismemberof" is not working for me in the "message" template. Is it meant to work here?

    It seems to work everywhere else. My code is exactly same as the places that I use it and it works as it should. (I copied and pasted it, so it is EXACTLY the same)

    Thank you :)
     
  2. Mike

    Mike XenForo Developer Staff Member

    What is the code you're using?
     
  3. RichardKYA

    RichardKYA Well-Known Member

    Code:
    <xen:if is="{xen:helper ismemberof, $user, 3,4,5,6}">
               <xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if>
             <xen:elseif is="{xen:helper ismemberof, $user, 2,7}" />
               <em class="userTitle" itemprop="title">{xen:phrase kya_active_member}</em>
             <xen:else />
               <em class="userTitle" itemprop="title">{xen:phrase kya_inactive_member}</em>
             </xen:if>
    
     
  4. borbole

    borbole Well-Known Member

    Can you use replace $user with $visitor and see if it would make any difference?
     
  5. RichardKYA

    RichardKYA Well-Known Member

    It needs to be $user because it is the user's title. I have the exact same code in member_list_item, message_user_info and a couple of other places and it works fine :confused:
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    The $user record isn't available in the message template.
     
  7. RichardKYA

    RichardKYA Well-Known Member

    Hello Brogan,

    How can I make it available?

    This is what I am trying to do....
    Screen Shot 2015-05-19 at 14.23.52.jpg

    ...but obviously at the moment everyone displays the "Inactive member" title.

    Thank you :)
     
  8. Steve F

    Steve F Well-Known Member

    Where are you wanting this to display? Use the message_user_info template to if you can.
     
  9. RichardKYA

    RichardKYA Well-Known Member

    I want it to display below where the user signature would be. It's for when viewing on mobile devices. On desktops, the message_user_info will display as normal.
     
  10. Mike

    Mike XenForo Developer Staff Member

    $message will contain the user info in this context.
     
  11. RichardKYA

    RichardKYA Well-Known Member

    @Mike

    Sorry to be a dumbass, but how can I use $message to see if a user ismemberof groups ? Looking at my code above, where would I put $message?

    Thank you :)
     
  12. Mike

    Mike XenForo Developer Staff Member

    You replace $user with $message, because the $message variable contains the user info. You can see this with the message_user_info include:
    Code:
    <xen:include template="message_user_info">
    <xen:map from="$message" to="$user" />
    </xen:include>
     
  13. RichardKYA

    RichardKYA Well-Known Member

    Awesome

    I did try that yesterday before I said "Sorry to be a dumbass......." and it didn't work.

    But it's OK, because as it turns out, I'm just a double dumbass (the doctors say that there is nothing they can do :(:ROFLMAO:)

    I missed the $user in this bit...
    Code:
    <xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if>
    
    ....but I've changed it now and it works fine (y)

    Thank you for your help :)
     

Share This Page