Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been looking into getting user pictures to link to nodeprofile rather than core profile page.
I found this code for pointing the picture to a person's usernode but wasn't sure how to modify it to direct it to nodeprofile:
/**
* Catch the theme_user_picture function and link to the usernode instead of linking to the userpage
*/
function phptemplate_user_picture(&$account) {
if (variable_get('user_pictures', 0)) {
if ($account->picture && file_exists($account->picture)) {
$picture = file_create_url($account->picture);
}
else if (variable_get('user_picture_default', '')) {
$picture = variable_get('user_picture_default', '');
}
if (isset(
$picture)) {
$alt = t('%user\'s picture', array('%user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
$picture = theme('image', $picture, $alt, $alt, '', false);
if (!empty($account->uid) && user_access('access content') && module_exist('usernode')) {
$nid = usernode_get_node_id($account);
$picture = l($picture, "node/$nid", array('title' => t('View user details.')), NULL, NULL, FALSE, TRUE);
}
return
"<div class=\"picture\">$picture</div>";
}
}
}
?>
I was thinking I could change this part
if (!empty($account->uid) && user_access('access content') && module_exist('usernode')) {
$nid = usernode_get_node_id($account);
to this
if (!empty($account->uid) && user_access('access content')) {
$nid = profile_get_node_id($account);
profile is the name of the nodeprofile content type.
thanks for your help.
Comments
Comment #1
lias CreditAttribution: lias commentedOr should it be:
Or is this code not doable for nodeprofile?
edit:
Nope, this code doesn't work, I got a undefined function for profile_get_node_id($account)
: (