English 中文(简体)
最新标识用户——博士
原标题:Users last login date - Drupal
  • 时间:2011-06-24 06:49:21
  •  标签:
  • drupal

In drupal how to display the user s last login date and Time.I tried out the code user->login It displays the current login time, But I want users previous login time and date.

问题回答

http://drupal.org/project/user_stats”rel=“nofollow” 用户统计模块可能为你们服务。 模块网页:

Provides commonly requested user statistics for themers, IP address tracking and Views integration. Statistics are:

  • Days registered
  • Join date
  • Days since last login
  • Days since last post
  • Post count
  • Login count
  • User online/offline
  • IP address

http://drupal.org/project/login_history”rel=“nofollow” 日志

Drupal dont在本地提供。 如果你需要使用,你可能会想在例如序列化的用户和用户之间增加数据阵列;用户标识(Using hook_user () for$ = “login”并在之后节省最新用户物体,然后你将能够将其排在下一个标识上。

我使用的解决办法是:追踪最后两个正日度(目前和前一个)。

/**
 * Implementation of hook_user()
 */
function your_module_user($op, &$edit, &$account, $category = NULL) {
  switch($op) {

    // Successful login
    case  load :
      // If it s less than two it means we don t have a previous login timtestamp yet.
      $account->custom_last_login = sizeof($account->custom_login_history) < 2 
        ? NULL 
        : array_pop($account->custom_login_history); 
      break;

    case  login :
      // If it s the first time, we don t have a history
      $login_history = is_array($account->custom_login_history) 
        ? $account->custom_login_history 
        : array();

      // Get rid of the old value.
      if (sizeof($login_history) == 2) {
        array_pop($login_history);
      }

      // Add to the history the current login timestamp.
      array_unshift($login_history, $account->login);

      user_save($account, array( custom_login_history  => $login_history));
      break;
  }
}

然后,在您的模板中,你仅使用<代码>/$user->custom_last_login。 如果空洞,就意味着我们没有以前的时间,在下一个标志之后将可找到。





相关问题
Drupal Multi-language: Simple strings not translated

I m adding additional languages to a Drupal site that I m building. Getting the translation of content working is fairly easy using the Internationalisation module. Yet, simple things such as date ...

Setting up a WYSIWYG editor for Drupal site users [closed]

Looking through the Drupal contrib modules, and after a few Google searches, it becomes evident that there are any number of choices and combos available to set up a WYSIWYG editor in Drupal. I m ...

Change size of user/password login box

I don t know how to change the size of the login username/password boxes on the drupal site that I m trying to build. I m stumbling through the theming, and don t know where to find the file that ...

How does Drupal provide an edit/review/publish model?

How does Drupal support a means to update and review a website before it is published? Does it only allow you to preview a page at a time before you publish it or is there a way to create a site ...

Term for rotating header

I m looking for terminology that describes this behavior: The header of a web-page contains a different image every time you visit it. Update: It is not an advertisement, but images related to the ...

Has anyone checked out Drupal 7? [closed]

Has anyone checked out a copy of Drupal 7 yet? What do people think? I m pretty excited about the PDO and all of the designers I work with a very excited about the new admin interface/structure. Do ...

热门标签