In my Drupal 7 project, I am using drupal_add_js to add JavaScript within the hook_user_login function.
Although drupal_get_js confirms that my JavaScript has been added, it seems to disappear when the page is loaded.
This is my code snippet:
function popups_user_login(&$edit, $account) {
$js = 'some inline js here';
drupal_add_js($js, array('type'=>'inline', 'weight'=>1));
drupal_add_js(drupal_get_path('module', 'popups').'/popups.js', array('weight'=>2));
}
The purpose of this module is to display a popup once the user logs in under certain conditions.
You can find a similar discussion on drupal.org here.
I am puzzled by why the JavaScript disappears and would appreciate any insights or help.
(I have tested this on two different Drupal 7 installations and encountered the same issue on both sites)