Extending Identities privacy settings to message user info and member card

Steve F

Well-known member
#1
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>
 

Aayush

Well-known member
#2
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.
 

Steve F

Well-known member
#3
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?
 

Aayush

Well-known member
#4
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:
#5
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?
 

Steve F

Well-known member
#6
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