I would like to perform an actoin if the user's last access time was last month.

Would this be through hook_user(), when $op is equal to "after_update"?

I assume the last access variable would be updated, and I could check.

  • Do you mean that when a uses logs in, you want to check if his previous login was more than a month ago? – marcvangend Sep 11 '11 at 20:35
  • Thanks Marc, yes, but as I understand checking access time can be more accurate, as a user may not necessarily logout for a week, but still come back and "access" the site. – giorgio79 Sep 12 '11 at 4:52

Drupal saves the timestamp of a user's last access, but by the time your can react to a user visiting the site, that value has already been overwritten with the current timestamp (that happens in sess_write()). I don't have a cut-and-paste solution for you, but there are some ideas how to store the previous timestamp for later use in this forum topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.