0

I'm using RealName module in D7 to show real names on nodes and in comments and would like to link the real name [user:first-name] [user:last-name] to a custom content type (a 'profile' page), instead of the standard 'user account'.

It is easy to use RealName in D6, but I've been searching for ages for a solution in D7.

I have read "Have username link to profile rather than regular userpage by default", but I am not using Content Profile.

I wondered if I need to 'preprocess' the user name, but can only read php and have no idea what to change there.

I have set the URLs for account pages to be [user:first-name]-[user:last-name]-account using URL alias patterns and the URLs of the custom content type I am trying to link to look like [user:first-name]-[user:last-name].

What is the simplest way to change the 'View user profile' link, which appears in comments and in node 'Authored by' to point at my custom user profiles instead of the standard 'user account's pages?

1 Answer 1

0

Did you try hook_username_alter()?

Alter the username that is displayed for a user.

Called by format_username() to allow modules to alter the username that's displayed. Can be used to ensure user privacy in situations where $account->name is too revealing.

I've used this occassionally, but I find sometimes there are instances where I felt it should have been called/used already and then wasn't (the Webform module submission report tables come to mind ...)

2
  • Thanks tenken, this looks like it might be an idea but, as mentioned, I can read some php ok but don't really know how to write it... any chance you can walk me through how and where to use hook_username_alter? Thanks!
    – olisb
    Commented Jun 19, 2013 at 12:15
  • I'm still wondering if there should be a simple way to do this using the a URL on my profile pages, or similar..? drupal.org/documentation/modules/realname says: "Link to homepage": This setting will appear only if there are URL fields in the profile, or, for Content Profile, "link" fields. If one of those fields is a link to the user's home page and you want it to be used instead of linking to the user's profile, choose that field here. anyone know how I can do something similar with RealName in D7?
    – olisb
    Commented Jun 19, 2013 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.