Use Template Conditionals to build user's display name directly from templates
If you are using the Template Conditionals or PHP in Templates plugins, Display Name adds a helper function to easily build a user's display name directly from templates.
Template Conditionals
If you are using the Template Conditionals plugin, it is required to add the helper functions to the list of allowed functions. This step is not required if you use the PHP in Templates plugin.
Build Display Names from Templates
Use any of the following tags to print out the desired display name:
For example, edit the
Each helper function accepts at least 2 boolean additional paramethers,
The following will build the display name with no group format nor profile link:
It is recommended to use
Regards.
Template Conditionals
If you are using the Template Conditionals plugin, it is required to add the helper functions to the list of allowed functions. This step is not required if you use the PHP in Templates plugin.
- Open file
/var/www/ougc.network/html/inc/plugins/phptpl_allowed_funcs.txt
- At the end of the file, find:
; yaml? - Add after:
ougcDisplayNameGet ougcDisplayNameGetByUsername
Build Display Names from Templates
Use any of the following tags to print out the desired display name:
<?=ougcDisplayNameGet((int) $userID)?>
<?=ougcDisplayNameGetByUsername((string) $userName)?>
For example, edit the
forumbit_depth1_forum_lastpost to build the last poster display name:<?=ougcDisplayNameGet((int) $lastpost_data['lastposteruid'])?>
Each helper function accepts at least 2 boolean additional paramethers,
$formatName and $profileLink respectively. The default for both is true.<?=ougcDisplayNameGet((int) $userID, (bool) $formatName, (bool) $profileLink)?>
<?=ougcDisplayNameGetByUsername((string) $userName, (bool) $formatName, (bool) $profileLink)?>
The following will build the display name with no group format nor profile link:
<?=ougcDisplayNameGet((int) $lastpost_data['lastposteruid'], false, false)?>
It is recommended to use
ougcDisplayNameGet() over ougcDisplayNameGetByUsername() when possible.Regards.