When you post a comment on any Drupal site, the post is followed by your name (if not anonymous). If you are not a registered user, Drupal links your name to whatever URL you stated. If you are a registered user, Drupal links your name to your site profile ("user/nnn").

So if you don't register for the site, you get a link. If you do register, you don't. This didn't seem fair to me. So I fixed it, on http://www.itskeptic.org at least.

In my theme (called "itskeptic.theme") I added the following theming routine which is exactly the same as the one out of includes/theme.inc except for the three lines inserted after "###"

function itskeptic_username($object) {

  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 16) .'...';
    }
    else {
      $name = $object->name;
    }

    if (user_access('access user profiles')) {
      $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
    }
    else {
      $output = check_plain($name);
    }
//###
    if ($object->profile_website > ' ') {
      $output .= ' (' . l('@', 'http://'.$object->profile_website, array('title' => t('View user website.'))) .')';
    }

  }
  else if ($object->name) {
    // Sometimes modules display content composed by people who are
    // not registered members of the site (e.g. mailing list or news
    // aggregator modules). This clause enables modules to display
    // the true author of the content.
    if ($object->homepage) {
      $output = l($object->name, $object->homepage);
    }
    else {
      $output = check_plain($object->name);
    }

    $output .= ' ('. t('not verified') .')';
  }
  else {
    $output = variable_get('anonymous', t('Anonymous'));
  }

  return $output;
}

instead of the "@" you could substitiute a nice link icon

Comments

twohills’s picture

Wow what a bug! Profile.module serialised the user profile info into the user->data field but only for some users. Your older and newer users will have profile data in the {profile_values} table, some in the middle will have profile in user->data. go figure!

So the code above does not work for most users. instead of those three lines inserted above, you need this (replace fid=6 with the fid number for the website field on your profiles or write even more code to go find it in {profile_fields}):

//###
    if (!($object->profile_website > ' ')) {
      $fid=6;
      $object->profile_website = db_result(db_query('SELECT value FROM {profile_values} WHERE uid = %d AND fid = %d', $object->uid, $fid));
    }
    if ($object->profile_website > ' ') {
     if (valid_url($object->profile_website) ) {
        if ( valid_url($object->profile_website,TRUE) ) { } else {
          $object->profile_website = 'http://'.$object->profile_website;
        }
        $output .= ' (' . l('@', $object->profile_website, array('title' => t('View user website.'))) .')';
      }
    }
//###
twohills’s picture

Someone may have a better way? but I ended up just hardcoding the link

        $output .= ' <a href="'. $object->profile_website
           . '" target="_blank" title="View user website"><img src="http://www.itskeptic.org/files/imageskeptic/home2.png"/></a>';
aterchin’s picture

That's fantastic. i completely agree with you, in that it doesn't seem fair that anonymous users get a website field while registered users by default get a link to their own view page. Sure, their view page can have all that info and more but in my humble opinion this makes me want to be a registered user even more.

Even better would be a option specific to the profile link field in which a user gets to CHOOSE the link they want for their name, displayed on comments/posts/forums/etc:
Select List:
choice 1 (default) : view page at users/'username' or whatever you've pathautoed.
choices 2 THRU n : profile_website 1, profile_website 2, profile_website 3

If anyone's attempted something similar to this I'm all ears. Just another out of the box benefit to registering.