Xenforo conditional

abdfahim

Well-known member
I want to show ad for all members EXCEPT those who are in
  • User group 3/4/5/6, AND
  • set the value of custom field (checkbox) my_idf = 1
So, I did the following, but it breaks the page. What is wrong with this conditional?

Code:
<xen:if is="{xen:helper ismemberof, $user, 3, 4, 5, 6} AND {$user.customFields.my_idf} AND {$user.customFields.my_idf} == '1'">

<xen:else />
ADSENSE CODE
</xen:if>
 
Thanks a lot, replacing $user with $visitor solved the issue I mentioned, but seems like {$user.customFields.my_idf} does not return anything even though I checked that in my profile (and the custom field has the value of 1). Is it the correct way to retrieve a custom checkbox field, or I should use the helper class?

Just FYI, I am using this code in the ad_thread_view_below_messages template.
 
That would be {$visitor.customFields.my_idf}
Oh sorry, actually I used just that like you said before, but still no value. I must have done something wrong then, in defining the custom field.


Code:
<xen:hook name="ad_thread_view_below_messages" />
<xen:if is="{xen:helper ismemberof, $visitor, 3, 4, 5, 6} AND {$visitor.customFields.my_idf} AND {$visitor.customFields.my_idf} == '1'">

<xen:else />
       AAAA: {$visitor.customFields.my_idf}
</xen:if>

Output: AAAA:
 
aah, so it turns out the checkbox custom fields do not return anything for {$visitor.customFields.my_idf}.

I solved it by setting value = "som_text" (instead of "1") for the custom checkbox field, and then replaced
Code:
{$visitor.customFields.my_idf} == '1'
with
Code:
{$visitor.customFields.my_idf.som_text}
 
Back
Top Bottom