Does anyone know how to override automatic linking to user/%.

Aka the links that show up in blocks such as "who's online" and "who's new" -> the link to a user's profile.

Comments

thomasmeadows’s picture

Well, I figured out I could use the rules module to overide it, sort of...But it still does not answer my question...lol

imrook’s picture

http://api.drupal.org/api/function/theme_username controls the display of usernames in Drupal. You can override this theme function in your theme to make the username not appear as a link.

thomasmeadows’s picture

function my_module_preprocess_theme_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, 15) .'...';
    }
    else {
      $name = $object->name;
    }

    if (user_access('access user profiles')) {
      $output = l($name, 'the_new_directory/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
    }
    else {
      $output = check_plain($name);
    }
  }
  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 (!empty($object->homepage)) {
      $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
    }
    else {
      $output = check_plain($object->name);
    }

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

  return $output;
}

This did not work ~_~. well I did it in my module though not in my theme. does it matter?