I need to do one of two things in Drupal
- have the ability to set a info message to a specific user to view next time they login. This message would show up in the standard $messages variable. I looked to see if drupal_set_message() had the capabilities but didn’t find it
- run a function everytime a page is loaded that would then look for some info that would then cause the drupal_set_message to be sent
I prefer the second option, if anyone has suggestions.
I would place code in hook_init(). Most of Drupal has been loaded and it is available on every page load.
Within that, you could query for a list of messages form the database and funnel them into drupal_set_message(). The $messages variable is stored in the session, so you need to call drupal_set_message() at the time you actually want to show the message.
Storing the need to present the message is a different challenge, and depends on how you determine a message needs to be set. If it is based simply on elapsed time, you can skip custom coding and go straight to Rules–defining triggers and actions based on user login date.
If it is a more dynamic messaging scheme, where you need to notify users of events which have happened in their absence, you might use write code based around the Message module or something like it, which would allow you to record messages to the database, and then query for anything dated since the user’s last login. In fact, I like that idea, it bears further thought…
A more specific question would help in recommending more targeted solutions.