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:
to
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.
<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 |
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 as above to
seems to have done the trick - username is now displaying as custom user attributes - First Name and Last Name instead. Many thanks
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()?>
<?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
Glad that worked out!
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.