Extending Identities privacy settings to message user info and member card

Steve F

Well-known member
I see in ViewPublic/Member.php the custom fields function. How can I take this and extend it to my template for my add-on, more specifically the template is used in the message user info and member card to display a users Identity (Gamer Tags) but I need this to abide by a users privacy settings.

I see this in Member.php
PHP:
        $customFieldsGrouped = $fieldModel->groupUserFields($customFields);
        if (!$userProfileModel->canViewIdentities($user))
        {
            $customFieldsGrouped['contact'] = array();
        }

Then is set
Code:
'customFieldsGrouped' => $customFieldsGrouped,

Passed to the template (member_view)
Code:
return $this->responseView('XenForo_ViewPublic_Member_View', 'member_view', $viewParams);

I can use this on the member_view page easily enough (as it is passed default to member_view) to do what it needs to but I need the same for my template.
Code:
<xen:if is="{$customFieldsGrouped.contact}">
CONTENT
</xen:if>
 
You can extend the actionCard() method of the XenForo_ControllerPublic_Member class and append the customFieldsGrouped variable to the viewParams and pass it to the member_card template. You can then access the var in the member_card template and display the gamertags accordingly.

Hope this helps.
 
Thanks, will look at that approach.

It is kind of confusing me a bit. I need to see if the $visitor is being followed by say a user that has posted, if so then show the identities. Is there a way I can make this global instead of having to append the variable to numerous templates?
 
In the member card thing, I remember an isFollowing or something like that is being sent to generate the members card. Maybe you can use that and check if the user is being followed.
 
Last edited:
Thanks, will look at that approach.

It is kind of confusing me a bit. I need to see if the $visitor is being followed by say a user that has posted, if so then show the identities. Is there a way I can make this global instead of having to append the variable to numerous templates?
You ever figure this out?
 
This bug report explains a bit. So I'm just using what is available by the core identities settings.

Using the below code in my templates.
HTML:
<xen:if is="({$user.allow_view_identities} == 'everyone' OR ({$user.allow_view_identities} == 'members' AND {$visitor.user_id}))"> 
Content Here
</xen:if>
 
Top Bottom