开发者

DRUPAL - How can I add user ID (UID) to the activation email oder user page?

How can I add the value user id (uid) from user db in开发者_运维问答 to the activation email?

like : "hi XY your ID is :1234"

and I would like to print out the id on the user page.

thx


For the E-mails you can do the following: In drupal admin go to Home » Administration » Configuration » People » Account settings, be sure you are on the settings tab.

if you then scroll to the bottom of the page (seven theme) you find a section named E-mail. There you can add:

hi [user:name] your ID is :[user:uid]

Add this to all e-mail templates the you want the user id in.

And to add this to the profile page you can add the following ing you template.php file:

/**
* Process variables for user-profile.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $account
 *
 * @see user-profile.tpl.php
 */
function THEMENAME_preprocess_user_profile(&$variables) {
  $account = $variables['elements']['#account'];

    // Helpful $user_profile variable for templates.
  foreach (element_children($variables['elements']) as $key) {
    $variables['user_profile'][$key] = $variables['elements'][$key];
  }

  //this is added to print user id
  $variables['user_profile']['uid']['#type'] = 'user_profile_item';
  $variables['user_profile']['uid']['#title'] = 'User ID';
  $variables['user_profile']['uid']['#markup'] = $account->uid;


  field_attach_preprocess('user', $account, $variables['elements'], $variables);
}

cheers, Jørgen

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜