Search code examples
phpdrupaldrupal-5

How to show user e-mail in Drupal 5.x profile (nodeprofile)?


The email field in user profiles in Drupal is as far as i understand not ment to be shown (for good and obvoius reasons).

But I still need to know how to show user e-mail in Drupal 5.x profile (nodeprofile)?


Solution

  • Change the theme_user_profile hook (add the function to your template.php located at your current theme folder), like this:

    function <your_theme_name>_user_profile($account, $fields) {
      // adding the email field to profile
      $email = array();
      $email["value"] =  check_plain($account->mail);
      $fields["email"][0] = $email;
      // end of adding the email field
    
      // the rest of the default profile hook taken from http://api.drupal.org/api/function/theme_user_profile/5
      $output = '<div class="profile">';
      $output .= theme('user_picture', $account);
      foreach ($fields as $category => $items) {
        if (strlen($category) > 0) {
          $output .= '<h2 class="title">'. check_plain($category) .'</h2>';
        }
        $output .= '<dl>';
        foreach ($items as $item) {
          if (isset($item['title'])) {
            $output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
          }
          $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
        }
        $output .= '</dl>';
      }
      $output .= '</div>';
    
      return $output;
    }
    

    Update. Sorry, didn't notice that you're using nodeprofile module. I've never used it, but am pretty sure the email can be shown the similar way