Posted by madymad on December 26, 2012 at 11:22am
Hi,
I want to send mail to user on first login. how can i achieve it..Can i use the last_login attribute of user table.or any other way available. any one help me.
Hi,
I want to send mail to user on first login. how can i achieve it..Can i use the last_login attribute of user table.or any other way available. any one help me.
Comments
Hmmm
This is tough because Drupal doesn't give us a hook for "Before the user logs in". Just one for after (and at that point the last_login has been updated already).
What I would do it create a new role called "Accessed" or something. Then (using the Rules module or with my own module through hook_user_login) I would set a rule that every time a user logged in I would check if they have the "Accessed" role and if they don't, send the email and assign the role.
Nice work,
i accept your concept, its a better option, Thanks.But till the new user login to the site, the last_login is set to null on user table, so if i put a condition on hook_user_login for null to send mail.
The problem with that is that
The problem with that is that hook_user_login is called after the user logs in not before and so the last_login is set to the current time by the time you can access it. So the mail will never be sent because the last_login will never be null when hook_user_login is called.
ok
Thats way my coding not reflecting any out put.any way i will follow your previous idea.thanks
---
Maybe this thread will help.