Here is my contextual explanation:

I would like to redirect on a special page for first time after login. But registering system is using an email validation, so the path to the first login is "user/reset/uid/*", which brings the user to its profile page to save a password when the user clicks the one-time login button. This is fine and using a redirect after register of any kind is overriding it, which I don't want to. So I'm looking for a data comparison with the Rules module.

My question: How can I compare as a condition with rules [account:last-access] or [account:last-login] with something that would say never?

The rule would be this:

  • Rules Event : After updating account (because of the one-time login password change)
  • Rules Condition : [account:last-login] = never
  • Rules Action : redirect toward my special welcome page

These are the modules used:

  • rules
  • reference with user reference sub-module
  • ajax register (which usefully rewrite login to home)

2 Answers 2


It looks that what you're trying to do implement (= do a data comparison with "never") is not an obvious thing to do. Therefor, you may want to go for a plan-b that, for sure, will implement what you're trying to achieve, i.e. "... redirect on a special page for first time after login ..." (as in your question). Read on for more details.

Create a custom rule that looks like so (in Rules export format, use the Rules UI to import it in your own site):

{ "rules_redirect_new_users_to_special_page" : {
    "LABEL" : "Redirect new users to special page",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_login" : [] },
    "IF" : [
      { "NOT user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "4" : "4" } } } }
    "DO" : [
      { "user_add_role" : { "account" : [ "account" ], "roles" : { "value" : { "4" : "4" } } } },
      { "redirect" : { "url" : "welcome\/newuser" } }

Some details about this rule:

  • Rules Event: User has logged in.
  • Rules Condition: User does NOT (!!!) have a role with role id = "4".
  • Rules Action:
    • Grant User the role with role id = "4".
    • Perform a page redirect to relative path welcome/newuser.

So this rule checks if a user does not yet have some (designated) role with role id = "4" (adapt to whatever role id that fits your case, and make sure this role is NOT yet granted when activating a new user id). If that's the case then the user is granted that role, followed by a page redirect to relative path welcome/newuser (adapt to whatever path that fits your case). Obviously, next time a user performs a login again, the Rules Condition will no longer be TRUE, and no more redirect will be performed.

Pretty similar to "... redirect on a special page for first time after login ..." (as in your question), no?


What is explained before in this answer, does require some extra (dedicate) role. If you rather want to keep the number of roles in your site to a minimum, you could also use the Flag module (as an alternative for such extra role). Some more details about this variation:

  • Define a "global" flag to flag users
  • Replace the Rules Condition (to check for the dedicated role), by another one like "Check if the user is NOT flagged" (by the global flag).
  • Replace the Rules Action (to grant the dedicated role), by another one like "Flag this user flagged" (by the global flag).

Voilà ... use the solution you prefer, either one will do ...

  • I can't try it because the website is currently over, but I am assuming this is a good idea. D7 it was.
    – Tritof
    Commented Oct 19, 2017 at 17:23
  • @Tritof Merci for the feedback (and accept / upvote) ... A bit late, but better later then never, n'est-çe pas? Commented Oct 19, 2017 at 17:39

Unless your site has been running since before 1970, I think you're fairly safe to compare them with zero.

The login and access columns of the users table both have a default of zero, so values will be zero for new users that haven't logged in/accessed the site yet.

  • not working for me. Tried both [account:last-access] or [account:last-login] = 0
    – Tritof
    Commented Mar 4, 2014 at 17:09
  • That means those values have already been updated on the account, so the account has been logged in to and has been accessed. So your query of 'never' can't work, because the record had no concept of 'never', other than those fields containing zeros. Do you have an 'original user' account object available? If so you may be able to use that, otherwise I think you're out of luck
    – Clive
    Commented Mar 4, 2014 at 17:48
  • oh. I am trying to use account-unchanged:last-access, but still nothing yet. Thanks for your help. I'll try something with url from user/reset maybe
    – Tritof
    Commented Mar 4, 2014 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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