• 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)?

Chris D

XenForo developer
Staff member
#2
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
 

Chris D

XenForo developer
Staff member
#3
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>