Posted by deverman on May 7, 2009 at 2:10am
Is it possible to trigger a rule only once the first time a user logs into their account. If I create an account for them I want them to be redirected to update their profile information.
Is it possible to trigger a rule only once the first time a user logs into their account. If I create an account for them I want them to be redirected to update their profile information.
Comments
I did something like this by
I did something like this by creating a specific role called 'verified user'. When the a user w/o verified user role logs in the rule takes effect. I was having trouble with endless path redirects so I had to just make a link to their profile page.
Then I have another rule that adds verified user role when specific profile field has some value.
You don't necessarily need
You don't necessarily need Rules for this - Logintoboggan already provides functionality similar to this.
Use role to control state
I have used logintoboggan, too. But when I don't need all it's functionality I do something similar with a role to indicate state. During a login event have a rule that checks for an existing role (such as user_has_prev_logged_in). The role does not exist, then assign the user to that role, then redirect the user to the profile information page. The next time the user logs in, that role will exist and the rule will not be triggered to redirect them. I do the same thing sometimes to control a one-time "welcome" message on the screen.
Would anyone know how to set
Would anyone know how to set the Rule to execute on when the user Validates via LoginToboggan?
Your help will be very much appreciated!
Yes it is possible. Please
Yes it is possible.
Please use the solution given here.
http://drupal.org/node/705402#comment-2687656
Cheers,
Sudhir
I've created video tutorials
I've created video tutorials for two ways of achieving this. One is based on a user profile field value, and the other is based on the number of logins or posts. Neither options use LoginToboggan.
http://www.slurpitup.com/drupal/redirect-users-on-first-login-using-rules-and-user-stats
http://www.slurpitup.com/drupal/redirect-user-using-rules-based-on-a-profile-field-value
I hope this helps!
Quick workaround
Don't know if someone still needs the answer.
An easy way to do so is to set the rule to fire on "user login" and add a condition on the field "last-login" checking that it's empty.
Hope it helps
Drupal Rules First Login
Hi there,
woriking with "last-login" didn't work for me. Seems that the Rules event is triggered after the "last-login" value has been set, it's value is not 0 at the moment when event occurs. But i found out, that using "last-access" works. I wrote a blog article about it on our Blog page. Perhaps it helps for other people who have problems with using "last-login".
Regards, Edin
Use last access instead of last login
All,
This is actually very simple in D7 using the Rules module. All you have to do is see if the value of the user's Last Access field is empty. When an account is created and the initial value of the Last Access is empty.
The value of this field is not set until sometime AFTER the rules have been run. So, all you have to do is setup a conditions in rules that check:
Here is an export of my rule and it has been working fine. If anyone finds any issues, please let me know. You should be able to import this rule into your site.
{ "rules_first_time_login" : {
"LABEL" : "first time login",
"PLUGIN" : "reaction rule",
"WEIGHT" : "1",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "user_login" : [] },
"IF" : [
{ "data_is_empty" : { "data" : [ "site:current-user:last-access" ] } },
{ "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "16" : "16" } } } }
],
"DO" : [
{ "drupal_message" : { "message" : "Welcome to Drupal Camp Florida. Please submit your session proposal below." } },
{ "redirect" : { "url" : "node\/add\/sess?destination=\/admin\/dashboard" } }
]
}
}
The role with a value of "16" is a role of "Speaker".
Dennis
Best way to target first log in
@densolis this worked perfectly! and very lightweight
glad to help
@capfive - glad to help.
cool
great stuff! many thanks