Changing username display to custom user attributes first name

Permalink Browser Info Environment
Discussion posts show the poster's username, I am looking to change this to custom user attribute first name and last name. Adjusting the following code does not change this from username:

<h4><?php  if ( $ui ) echo $ui->getUserName()?></h4>


to

<h4><?php  if($ui) echo $ui->getAttribute('Fname') . ' ' . $ui->getAttribute('Lname');?> </h4>


in packages\discussion\blocks\discussion_post_list\view.php and packages\discussions\elements\discussion_messages.php does not change anything and username is still displaid.

Any help on this much appreciated.

Type: Discussion
Status: New
xigo
View Replies:
EvanCooper replied on at Permalink Reply
EvanCooper
Hi Xigo,

A.) Make sure you are overriding, not editing package files directly:
https://www.concrete5.org/documentation/how-tos/developers/change-th...

B.) If it's not changing, perhaps there are overrides already in place? I would check your site roots override directories. Off the top of my head, I know that Discussions uses a lot of elements as well, so make sure what you're actually looking to override isn't actually in an element.
xigo replied on at Permalink Reply
xigo
Hi EvanCooper that is really useful. I have followed your lead on using override directories rather than editing package files directly. And have located the right files to move to the override directories and alter as follows

packages/discussions/elements/discussion_messages.php
packages/discussions/blocks/discussion_post_list/templates/simple.php
packages/discussions/blocks/discussion_topics/view.php

moved to

elements/discussion_messages.php
blocks/discussion_post_list/templates/simple.php
blocks/discussion_topics/view.php

and editing
<?php  if ( $ui ) echo $ui->getUserName()?>
as above to

<?php  if($ui) echo $ui->getAttribute('Fname') . ' ' . $ui->getAttribute('Lname');?>


seems to have done the trick - username is now displaying as custom user attributes - First Name and Last Name instead. Many thanks
EvanCooper replied on at Permalink Reply
EvanCooper
Glad that worked out!

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.