XF 2.2 Hiding usernames from users not logged in?

Jakko W

Member
In the forum I moderate, use of real names as usernames is mandatory for everyone who actually posts. Recently, though there has been some discussion about the privacy aspects when one member who feels strongly about this, discovered that his name was also visible to visitors who are not logged into the forum. (Quite why he had assumed otherwise is beyond me, but that’s not really relevant, I think.)

So, my question is: Is there a way to hide or abbreviate usernames, except to users who are actually logged in?

Trying to find a solution, I discovered XenForo has “conditionals” that sound like they might be a solution, but I haven’t been able to locate any documentation for them, so I don’t know what possibilities they have, or even really how to add them to my forum’s files (let alone where). Would this be a way to do it, for example by adding a conditional to the relevant files that calls a custom JavaScript function to obfuscate the username?
 
You can fix the problem with a conditional statement.
Open the template message_macros.
Search for the line :

Code:
<h4 class="message-name"><xf:username user="$user" rich="true" defaultname="{$fallbackName}" itemprop="name" /></h4>
directly above this you add the statement:

Code:
<xf:if is="$xf.visitor.user_id">

And after the found line :

Code:
</xf:if>
After that only meber can see the username.


Code:
<xf:if is="$xf.visitor.user_id">
<h4 class="message-name"><xf:username user="$user" rich="true" defaultname="{$fallbackName}" itemprop="name" /></h4>
</xf:if>
 
You can fix the problem with a conditional statement.
Open the template message_macros.
Search for the line :

Code:
<h4 class="message-name"><xf:username user="$user" rich="true" defaultname="{$fallbackName}" itemprop="name" /></h4>
directly above this you add the statement:

Code:
<xf:if is="$xf.visitor.user_id">

And after the found line :

Code:
</xf:if>
After that only meber can see the username.


Code:
<xf:if is="$xf.visitor.user_id">
<h4 class="message-name"><xf:username user="$user" rich="true" defaultname="{$fallbackName}" itemprop="name" /></h4>
</xf:if>

That only hides them in posts. They are still viewable everywhere else.
 
Thanks for the pointer, but as @Ozzy47 says, that would only hide them in the posts. I could, of course, go through the other templates and add similar lines where necessary, but this is a lot of work on something I don’t know my way around at all. Maybe a better question would be: is there a function that gets called whenever the forum is about to display a username, which I can modify, override, or similar?
 
Back
Top Bottom