Jump to content

Display the user name, different from login


hafa
 Share

Recommended Posts

How can I display the real user's name instead of the one used in the login?

For example, let's say my user login is "admin" or "hafa"

But I want to display my real name on the site, like so:

"Posted by Rafael"

So the question is how to get real names, instead of the users login.

Link to comment
Share on other sites

The "user" is basically just another Page. So you can add a field to the user template and access it from the API.

  1. Create a field for your name, e.g. fullname. Or use an existing one
  2. Go to Site > Setup > Templates and then click on "Filter". Enable that system-templates are shown
  3. Edit the "user" template and add your fullname field. Save
  4. Go to your users profile and enter your name
  5. On the front end side, access the field as usual with $user->fullname

EDIT:

Output the "fullname" field of the user, that last modified the page: $page->modifiedUser->fullname.

  • Like 5
Link to comment
Share on other sites

The "user" is basically just another Page. So you can add a field to the user template and access it from the API.

  1. Create a field for your name, e.g. fullname. Or use an existing one
  2. Go to Site > Setup > Templates and then click on "Filter". Enable that system-templates are shown
  3. Edit the "user" template and add your fullname field. Save
  4. Go to your users profile and enter your name
  5. On the front end side, access the field as usual with $user->fullname

EDIT:

Output the "fullname" field of the user, that last modified the page: $page->modifiedUser->fullname.

Thank you Philipp =) I hadn't noticed the system-templates.

What the "modifiedUser" in the code means?

Link to comment
Share on other sites

  • 9 months later...

So how do I get the "fullname" field to appear in the profile edit view? Even my superuser can't see it.

Another strange thing I noticed: in preparation for CSV import of users, I added the title field to the user template (in addition to fullname). If I input a fullname and a title for my superuser + tick a checkbox to add a role, none of the values get saved!

Link to comment
Share on other sites

You need to edit the ProcessProfile module. There you can chose out of the template's fields which one are visible.

Wow, I never would have thought of that.

The unrelated problem of not being able to assign my superuser to a new role remains (the same behavior is in another site without any user template modifications). Yet in the other site my superuser also has the "blog-author" role.. Well, I can live with it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...