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

XF 1.2 Hide Username

Itworx4me

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

Jeremy

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

Itworx4me

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

Itworx4me

Well-known member
#6
The last sentence of that quote explains it.
I changed $user.customFields.nick_name and this is what I get:

xen1.PNG

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>