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

XF 1.2 Custom User Field - Only for admin to view

Discussion in 'XenForo Questions and Support' started by Tong, Oct 1, 2013.

  1. Tong

    Tong Member

    How to make custome user fields that can be viewed in user profile only by admins, but usual users cannot see it.

    For example for support forum of software it essential to fast check of user license.
     
  2. Mike

    Mike XenForo Developer Staff Member

    You would want to make the field not user editable (or editable only once if you want them to fill it in initially). Make sure it's not selected to show up in messages or on the profile page as well.

    If it still must be displayed in the front end, you'd need to customize the appropriate templates to display it in specific conditions.
     
  3. Tong

    Tong Member

    That was the answer?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    Tong likes this.
  5. Tong

    Tong Member

    Cool. Thank you guys.
     
  6. Ladegro

    Ladegro Member

    Just to add a small question to this as I want to achieve the same.

    I'm having members enter their personal data but of course that should only be visible to other members of the group, not to other ones.
    So I'd like to somehow define which groups are able to view a certain custom user field.

    Do I need an addon for this or would it become manual template edits?
     
  7. Tong

    Tong Member

    mine case
    Code:
    <xen:if is="{$visitor.is_admin}">
    <xen:if hascontent="true">
        {xen:helper userFieldTitle, my_identifier}:
        <xen:contentcheck>
            {xen:helper userFieldValue, $userFieldsInfo.my_identifier, $user, {$user.customFields.my_identifier}}
        </xen:contentcheck>
    </xen:if>
    </xen:if>
    replace my_identifier with custom field

    Ladergo
    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, x}">
    <xen:if hascontent="true">
        {xen:helper userFieldTitle, my_identifier}:
        <xen:contentcheck>
            {xen:helper userFieldValue, $userFieldsInfo.my_identifier, $user, {$user.customFields.my_identifier}}
        </xen:contentcheck>
    </xen:if>
    </xen:if>
    user group x
     
  8. Ladegro

    Ladegro Member

    And to which template should this be added? Preferably I'd make this a configurable option in admin panel but I suppose that's a bit too much to ask right ;-)
     
  9. Tong

    Tong Member

    member_card or message_user_info
     

Share This Page