How to use hook_user_login and hook_user_logout to output content to the page I came across this post: execute a php code after a user login and I implemented the accepted solution. In my implementation, however, I'm trying to output content to the page. This simply doesn't show up. My module name is "alert", and here's the code:

alert.module

&lt;?php

function alert_user_login(&amp;$edit, $account) {
  for ($i=0; $i &lt; 1000; $i++) { 
    echo 'hi&lt;br&gt;';
  }
}


alert.install

&lt;?php

function alert_install() {
  // Set the module weight so it can override other modules.
  db_query("UPDATE {system} SET weight = 99 WHERE name = 'alert'");
}

function alert_uninstall() {
  // Remove the module from the system table
  db_query("DELETE FROM {system} WHERE name = 'alert'");
}


alert.info

; $Id$
name = Alert
description = Present dialogs or perform redirects based on certain events
core = 7.x


I'm implementing this in my theme's template.php file. Should this work?
It will not work in template.php
You need to add this in a module file, check here on howto
instead of myTheme it will be modulename
If module name is foo then it will be foo_user_login

    // @file : foo.module
    function foo_user_login(&amp;$edit, $account) {
      fluenz_user_function($account-&gt;uid);
    }
    // and this function name was also different just an FYI
    function fluenz_user_function($uid) {
      for ($i=0; $i &lt; 1000; $i++) { 
        echo 'hi&lt;br&gt;';
      }
    }