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

Problem with this...

Matthew Hawley

Well-known member
#1
Im trying to create an addon where it shows details about the author on the author's resource list page. So far i have the joined date and gender working but I cant seem to get the rest working.

Here is what I have:

Code:
<h3>Author Information</h3>
            <xen:if is="{$xenOptions.resourceListAuthRegDate} AND {$user.user_id}">
                    <dl class="pairsJustified">
                        <dt>{xen:phrase joined}:</dt>
                        <dd>{xen:date $user.register_date}</dd>
                    </dl>
                </xen:if>
             
                <xen:if is="{$xenOptions.resourceListAuthGender} AND {$user.gender}">
                    <dl class="pairsJustified">
                        <dt>{xen:phrase gender}:</dt>
                        <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:else />{xen:phrase female}</xen:if></dd>
                    </dl>
                </xen:if>
             
                <xen:if is="{$xenOptions.resourceListAuthOccupation} AND {$user.occupation}">
                    <dl class="pairsJustified">
                        <dt>{xen:phrase occupation}:</dt>
                        <dd itemprop="role">{xen:string censor, $user.occupation}</dd>
                    </dl>
                </xen:if>
             
                <xen:if is="{$xenOptions.resourceListAuthLocation} AND {$user.location}">
                    <dl class="pairsJustified">
                        <dt>{xen:phrase location}:</dt>
                        <dd><a href="{xen:link 'misc/location-info', '', 'location={xen:string censor, $user.location, '-'}'}" target="_blank" rel="nofollow" itemprop="address" class="concealed">{xen:string censor, $user.location}</a></dd>
                    </dl>
                </xen:if>
         
                <xen:if is="{$xenOptions.resourceListAuthHomepage} AND {$user.homepage}">
                    <dl class="pairsJustified">
                        <dt>{xen:phrase home_page}:</dt>
                        <dd><a href="{xen:string censor, $user.homepage, '-'}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>
                    </dl>
                </xen:if>
             
                <xen:if is="{$xenOptions.resourceListAuthCustomFields} AND {$user.customFields}">
                <xen:foreach loop="$userFieldsInfo" key="$fieldId" value="$fieldInfo">
                    <xen:if is="{$fieldInfo.viewable_message}">
                        <xen:if hascontent="true">
                            <dl class="pairsJustified userField_{$fieldId}">
                                <dt>{xen:helper userFieldTitle, $fieldId}:</dt>
                                <dd><xen:contentcheck>{xen:helper userFieldValue, $fieldInfo, $user, {$user.customFields.{$fieldId}}}</xen:contentcheck></dd>
                            </dl>
                        </xen:if>
                    </xen:if>
                </xen:foreach>
                </xen:if>
 

Chris D

XenForo developer
Staff member
#3
If you changed it to $visitor then it won't work as you want it to.

$visitor is always the currently logged in user. So setting it to $visitor will show your own information on every user's page.

The reason $user doesn't work is because sometimes database queries will select and use specific fields rather than an entire table.

You should use:
{xen:helper dump, $user}

To see what information is stored in the array.

I can't stress this enough to you or anyone else: use the tools available to you. All the info is right there.

Not just you but in this forum I see the most basic things asked when the most basic debug solution will tell you everything you need to know.

If you dump $user and it doesn't contain the info you want then you would need to modify the query that fetches the information.