The Realname module (http://drupal.org/project/realname) allows you display someone's name instead of their login (see http://drupal.org/node/192056). Through it's settings, I can eliminate the login names that User Relationships output in most places. However, I had to alter the code to change the login name to their Realname where it says "Become 's ".
Please review the following code change and consider rolling into your code so other can benefit as well. The changes were made to user_relationships/user_relationships_ui/user_relationships_ui.theme.inc
lines
16 to 47. There were 2 instances of the same change.
Previous code:
$relate_to->name
Altered code:
theme('username', $relate_to, array('plain' => TRUE))
Here's what lines 16 to 47 look like after the change:
/**
* Create relationship link
*/
function theme_user_relationships_request_relationship_link($relate_to) {
return l(
t('Create a relationship with %name', array('%name' => theme('username', $relate_to, array('plain' => TRUE)))),
"relationship/{$relate_to->uid}/request",
array(
'query' => drupal_get_destination(),
'html' => TRUE,
)
);
}
/**
* Create a direct relationship link
*/
function theme_user_relationships_request_relationship_direct_link($relate_to, $relationship_type) {
//safety, revert to a generic link
if (!isset($relationship_type)) {
return theme('user_relationships_request_relationship_link', $relate_to);
}
return l(
t("Become %name's %rel_name", array('%name' => theme('username', $relate_to, array('plain' => TRUE)), '%rel_name' => ur_tt("user_relationships:rtid:$relationship_type->rtid:name", $relationship_type->name), '%rel_plural_name' => ur_tt("user_relationships:rtid:$relationship_type->rtid:plural_name", $relationship_type->plural_name))),
"relationship/{$relate_to->uid}/request/{$relationship_type->rtid}",
array(
'query' => drupal_get_destination(),
'html' => TRUE,
'attributes' => array('class' => 'user_relationships_popup_link'),
)
);
}
Comments
Comment #1
3dloco CreditAttribution: 3dloco commentedThanks Benlotter! This worked of me, +1 for adding this feature ;)
Comment #2
Jakob Stoeck CreditAttribution: Jakob Stoeck commentedI'd like to see this change committed like the op wrote or like this:
strip_tags(theme('username', $relate_to))
instead of the real name-specific part.That way if a user doesn't have the realname module nothing changes for him. But if he implements theme_username in his template.php and rolls his own username solution without changing the theme_username signature this works like on the rest of the site. And it works with the realname plugin, too.
Comment #3
imDhaval CreditAttribution: imDhaval commentedlove to sub +1
Comment #4
YK85 CreditAttribution: YK85 commented+1 subscribing
Comment #5
bwinett CreditAttribution: bwinett commented+1
Comment #6
Liliplanet CreditAttribution: Liliplanet commentedfabulous thank you! works perfect ..
Comment #7
capellicI had to add a couple of tokens to handle the themed username per @Jacob Stoeck's suggestion in #2 above for notification emails:
I've pasted the whole function below- it's in user_relationships/user_relationships_mailer/user_relationships_mailer.inc.
Comment #8
mrf CreditAttribution: mrf commentedTagging for a closer look.
Comment #9
mrf CreditAttribution: mrf commentedComment #10
serg.remote CreditAttribution: serg.remote commentedSuggestion in #2 works fine for me. I've also changed $requestee->name to strip_tags(theme('username', $requestee)) in user_relationships_ui.forms.inc lines 147-149.
Comment #11
btown CreditAttribution: btown commented+1