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 thread Omar G. 3 Apr, 2025, 6:26 am

Plugin Releases Plugin Contract Thread

New thread Omar G. 3 Apr, 2025, 6:02 am

Plugin Releases Plugin Extra Forum Permissions

New reply Omar G. 3 Apr, 2025, 4:34 am

Plugin Releases Plugin Forum Cleaner

New reply Omar G. 3 Apr, 2025, 3:59 am

Plugin Releases Plugin Lock Content

New thread Omar G. 3 Apr, 2025, 3:57 am

Plugin Releases Plugin Forum Cleaner

New thread Omar G. 3 Apr, 2025, 3:35 am

Plugin Releases Plugin Lock Content

New thread Omar G. 3 Apr, 2025, 2:16 am

Plugin Releases Paid Plugin Moderator Quick Buttons

New thread Omar G. 29 Mar, 2025, 1:44 am

Plugin Releases Paid Plugin Awards Rules

New thread Omar G. 27 Mar, 2025, 5:53 pm

Plugin Releases Plugin My2FA

New reply Omar G. 23 Mar, 2025, 10:57 am

Plugin Releases Plugin Awards



Current time: 17 Apr, 2025 11:54 am