如何在 Drupal 5.x 配置文件(nodeprofile)中显示用户电子邮件?

发布于 2024-07-19 09:05:19 字数 112 浏览 6 评论 0原文

据我所知,Drupal 中用户配置文件中的电子邮件字段不会显示(出于充分且明显的原因)。

但我仍然需要知道如何在 Drupal 5.x 配置文件(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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

假情假意假温柔 2024-07-26 09:05:19

将电子邮件 CCK 字段添加到您的节点配置文件 CCK 类型。

有关更多详细信息,请参阅电子邮件字段模块。 以下是其项目页面的摘录:

特点:

  • 验证电子邮件
  • 将地址转换为 mailto 链接
  • 电子邮件地址加密
  • 联系表单(请参阅显示设置)
  • 提供令牌(对于 D 7.x:使用实体 API 中的实体令牌)
  • 向视图公开字段
  • 可以与规则一起使用
  • 面板集成

Add an email CCK field to your node profile CCK type.

For more details, refer to the Email Field module. Here is an excerpt from its project page:

Features:

  • validation of emails
  • turns addresses into mailto links
  • encryption of email addresses
  • contact form (see Display settings)
  • provides Tokens (for D 7.x: use Entity tokens from the Entity API)
  • exposes fields to Views
  • can be used with Rules
  • Panels Integration
臻嫒无言 2024-07-26 09:05:19

更改 theme_user_profile 挂钩(将该函数添加到位于当前主题文件夹的 template.php 中),如下所示:

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;
}

更新。 抱歉,没有注意到您正在使用 nodeprofile 模块。 我从未使用过它,但我很确定电子邮件可以以类似的方式显示

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

浅忆 2024-07-26 09:05:19

看下$user比。

global $user;
// You can use dsm with the devel module instead of print_r
print_r($user);

您也可以使用此模块http://drupal.org/project/logintoboggan

Look under $user than.

global $user;
// You can use dsm with the devel module instead of print_r
print_r($user);

You can work with this module also http://drupal.org/project/logintoboggan?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文