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

Checking if custom field is set to a value?

Discussion in 'Styling and Customization Questions' started by realwx, Feb 22, 2013.

  1. realwx

    realwx Member

    Right now I'm editing the XenForo templates to check to see if a user field is entered. It is a dropdown in "Preferences" with values correlating with 4 for Group A, 5 for Group B, etc. I'm using <xen if="{$user.customFields.a_field_in_preferences} == '4'">...</xen:if>, however {$user.customFields.fieldname} is usually blank. This is in relation to editing a template for the postbit section. Is there a separate variable I'm missing?

    (Sorry if I'm making a lot of posts, still new to xenforo programming and everything.)
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Usually blank? Some users might not have a value entered for that field yet. Are you intending to have some default value for existing users?
     
  3. realwx

    realwx Member

    The default value is blank, yes. I'm trying to do a template where if the field is set, display an image like:

    Code:
    <xen:if="{$user.customFields.preferenceField} == '4'">
    <img src="/path/to/image.png" />
    </xen:if>
    No matter what is picked for "preferenceField" for the user, the variable's value is always blank. What I'm wondering is if I have the wrong name of it, or whether you can't fetch custom personal details/contact info/preferences fields in postbit?
     
  4. Syndol

    Syndol Guest

    Try using "is":
    <xen:if is=
     
    CNK and Jake Bunce like this.

Share This Page