Show full name instead of username if available?



  • Anyway to show a users full name instead of a username when they post?

    Thanks,


  • Plugin & Theme Dev

    @whitts you will have to modify the template in the theme.

    If you are using Persona theme... modify this line

    https://github.com/NodeBB/nodebb-theme-persona/blob/master/templates/partials/topic/post.tpl#L16

    change that line to...

    <a href="<!-- IF posts.user.userslug -->{config.relative_path}/user/{posts.user.userslug}<!-- ELSE -->#<!-- ENDIF posts.user.userslug -->" itemprop="author" data-username="{posts.user.username}" data-uid="{posts.user.uid}">{posts.user.fullname}</a>

    Full Name is an optional field so not everybody updates it in their profile. You might want to check if it's available before displaying it.

    <a href="<!-- IF posts.user.userslug -->{config.relative_path}/user/{posts.user.userslug}<!-- ELSE -->#<!-- ENDIF posts.user.userslug -->" itemprop="author" data-username="{posts.user.username}" data-uid="{posts.user.uid}"><!-- IF posts.user.fullname -->{posts.user.fullname}<!-- ELSE -->{posts.user.username}<!-- ENDIF posts.user.fullname --></a>



  • @pichalite said:

    <a href="<!-- IF posts.user.userslug -->{config.relative_path}/user/{posts.user.userslug}<!-- ELSE -->#<!-- ENDIF posts.user.userslug -->" itemprop="author" data-username="{posts.user.username}" data-uid="{posts.user.uid}"><!-- IF posts.user.fullname -->{posts.user.fullname}<!-- ELSE -->{posts.user.username}<!-- ENDIF posts.user.fullname --></a>

    Works perfectly. Thank you very much



  • This post is deleted!

Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.