RealName module compatibility
Plazmus - April 19, 2009 - 09:29
| Project: | Guestbook |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
I use realname module and unfortunately guestbook 6.x-1.1 is showing username instead of user real name.
I've changed your code slightly and it works for me, here is what I've done:
function theme_guestbook_user_picture($uid) {
$account = user_load(array('uid' => $uid));
- $output = $account->name;
+ $output = theme('username', $account, array('plain' => TRUE));
- $output = l($account->name ? $account->name : variable_get('anonymous', 'Anonymous'), $user_link, array('attributes' => array('title' => $user_text)));
+ $output = l($output ? $output : variable_get('anonymous', 'Anonymous'), $user_link, array('attributes' => array('title' => $user_text)));I'm learning, so if there is a better way to do that feel free to correct me, but if that's ok please update your code as I think many people would like to have a real name displayed.

#1
2.x provides an integration with User Display API, which allows to display arbitrary stuff for or instead of the username.
#2
This is pretty nice! I think guestbook will served me right... and i'm looking forward the 2.x version. is it too dangerous to use the 2.x-dev version?
I tried this function override above and it's ok but I'd like to show the user name as a link also... is it possible?
#3
I'm not sure if I understand what you saying, because I have user name displayed as a link to user profile.
There was also username (not realname) displayed in alt text for profile images like "test's picture", so I made one more change:
<?php
function theme_guestbook_user_picture($uid) {
$account = user_load(array('uid' => $uid));
- $output = $account->name;
+ $user_name = theme('username', $account, array('plain' => TRUE));
- $output = l($account->name ? $account->name : variable_get('anonymous', 'Anonymous'), $user_link, array('attributes' => array('title' => $user_text)));
+ $output = l($user_name ? $user_name : variable_get('anonymous', 'Anonymous'), $user_link, array('attributes' => array('title' => $user_text)));
- $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
+ $alt = t("@user's picture", array('@user' => $user_name ? $user_name : variable_get('anonymous', 'Anonymous')));
?>
@a.luiz.n I hacked the module as I need slightly different functionality, but if you only overwrite it in template.php please post code as it probably will be useful for others as there is no "User Display API" for drupal 6.
#4
I changed the return line to show the username as a link:
return "<a href=\"/user/".$account->uid."\">".$output."</a>";Is there a way to show the user realname? I have lots of trouble with realname...
In a close future I'd like to show the user picture close to their name, but I use imagefield + imagecache and not the core user picture.