Community & Support

how to show a triggerd welcome message only on the first login?

I show a user welcome message on my site, triggered on user login. However, I want to restrict this only to the first or the initial few logins of a new user. Is there a way to achieve this non-programmatically? How do I check if it is the first or 'N' th login?

thanks!

Comments

User Stats

I've never used it myself, but you might want to check out User Stats, which includes a login counter. You'd still need a helper module to produce the count-sensitive messaging though. The idea is something like this VERY crude example:

function hook_user($op, &$edit, &$account, $category = NULL) {
  // $account assumes you have a fully loaded user object containing user stat properties
  if ($op == 'login') {
    switch ($account->login_count) {
      case 0:
      case 1:
         drupal_set_message(t("Hey, welcome new user!"));
         break;
      case 2:
         drupal_set_message(t("Hey, you look familiar..."));
         break;
      default:
        drupal_set_message(t("Hey, good to see you again old-timer."));
    }
  }
}

I am looking for the same

I am looking for the same thing. Can anyone verify that this works?

Thanks

+1

+1