XF 1.2 Hide Username

Itworx4me

Well-known member
I would like to hide the username to the Unregistered usergroup and replace it with custom user field. How do I go about this?

Thanks,
Itworx4me
 
Find:
Code:
            <xen:username user="$user" itemprop="name" rich="true" />

Surround it with a conditional:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
</xen:if>

However, since you want to display something else, you'll want to add an else statement:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
<xen:else />
      <a href="#" class="username" itemprop="name">$user.customFields.x</a>
</xen:if>

Change x to the field ID. The above example is for message_user_info. You'll need to find all occurrences and update accordingly.
 
Find:
Code:
            <xen:username user="$user" itemprop="name" rich="true" />

Surround it with a conditional:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
</xen:if>

However, since you want to display something else, you'll want to add an else statement:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
<xen:else />
      <a href="#" class="username" itemprop="name">$user.customFields.x</a>
</xen:if>

Change x to the field ID. The above example is for message_user_info. You'll need to find all occurrences and update accordingly.
Thank you
 
Find:
Code:
            <xen:username user="$user" itemprop="name" rich="true" />

Surround it with a conditional:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
</xen:if>

However, since you want to display something else, you'll want to add an else statement:
Code:
<xen:if is="$visitor.user_id">
      <xen:username user="$user" itemprop="name" rich="true" />
<xen:else />
      <a href="#" class="username" itemprop="name">$user.customFields.x</a>
</xen:if>

Change x to the field ID. The above example is for message_user_info. You'll need to find all occurrences and update accordingly.
$user.customFields.x doesn't work. I tried $vistor.customFields.x and that doesn't work either. Any other suggestions?

Thank,
Itworx4me
 
The last sentence of that quote explains it.
I changed $user.customFields.nick_name and this is what I get:

xen1.webp

Code:
<xen:if is="{$visitor.user_id}">
                            <xen:username user="$user" itemprop="name" rich="true" />
                            <xen:else />
                            <a !href="" class="username" itemprop="name">$user.customFields.nick_name</a>
                        </xen:if>
 
Top Bottom