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.

  1. Open file /var/www/ougc.network/html/inc/plugins/phptpl_allowed_funcs.txt
  2. At the end of the file, find:
    ; yaml?
  3. 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.
Files

There are currently no posts to display. Be the first one to leave a reply.
Stream

« see more

New reply Omar G. 3 Jul, 2025, 3:12 am

Plugin Releases Plugin Feedback

New thread Omar G. 3 Jul, 2025, 2:55 am

Plugin Releases Plugin Feedback

New reply Omar G. 2 Jul, 2025, 1:13 am

Plugin Releases Plugin Lock Content

New reply Omar G. 30 Jun, 2025, 6:12 am

Plugin Releases Plugin Extra Forum Permissions

New reply Omar G. 30 Jun, 2025, 4:21 am

Plugin Releases Plugin Awards

New reply Omar G. 18 Jun, 2025, 11:05 am

Plugin Releases Plugin Awards

New thread Omar G. 23 Apr, 2025, 4:03 am

Plugin Releases Plugin Online Users List

New reply Omar G. 22 Apr, 2025, 7:35 pm

Plugin Releases Paid Plugin Discord Connect

New thread Omar G. 22 Apr, 2025, 7:35 pm

Plugin Releases Paid Plugin Discord Connect

New reply Omar G. 21 Apr, 2025, 5:36 am

Plugin Releases Plugin Custom Rates



Current time: 10 Jul, 2025 5:32 pm