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

Display custom field to specific user group(s)?

Discussion in 'Styling and Customization Questions' started by Mike Tougeron, Jan 22, 2013.

  1. Mike Tougeron

    Mike Tougeron Well-Known Member

    Is there an easy way to display a custom field ONLY to a specific user group(s)?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The best way of doing it is a template edit - (You said easy, not "ideal" :))

    So you would probably uncheck all of the boxes e.g. (viewable_profile, viewable_message) etc.

    But then place this code in your template:

    Code:
    <xen:if hascontent="true" && {xen:helper ismemberof, $visitor, 999}>
    	<dl class="pairsInline userField_FIELD_ID">
    		<dt>{xen:helper userFieldTitle, FIELD_ID}:</dt>
    		<dd><xen:contentcheck>{xen:helper userFieldValue, $userFieldsInfo.FIELD_ID, $user, {$user.customFields.FIELD_ID}}</xen:contentcheck></dd>
    	</dl>
    </xen:if>
    That should work... where "999" is your user group ID and FIELD_ID is your field ID
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    Sorry, code was pretty much all wrong:

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, 999}">
    	<xen:if hascontent="true">
    		<dl class="pairsInline userField_FIELD_ID">
    			<dt>{xen:helper userFieldTitle, FIELD_ID}:</dt>
    			<dd><xen:contentcheck>{xen:helper userFieldValue, $userFieldsInfo.FIELD_ID, $user, {$user.customFields.FIELD_ID}}</xen:contentcheck></dd>
    		</dl>
    	</xen:if>
    </xen:if>
     
    Jake Bunce likes this.
  4. Mike Tougeron

    Mike Tougeron Well-Known Member

    Lol, yeah, I probably should have been more specific. That's the solution I was able to come up with but it didn't seem very optimal. :/ Thanks for your help.
     

Share This Page