0

I need to add a Javascript file only once immediately after logging in - which will open another URL in a new window.

Without using _SESSION what'll be the right place to add drupal_add_js function only once after logging in?

Is there a hook which is called in the very first logged-in page?

1 Answer 1

0

Add the JS file inside the implementation of hook_user_login().
Function docs:

The user just logged in. Parameters

$edit: The array of form values submitted by the user.

$account: The user object on which the operation was just performed.

4
  • It does not work.
    – AgA
    Commented Jun 12, 2014 at 8:54
  • What do you mean by does not work? Can you paste the code by editing the question on what you've tried?
    – AjitS
    Commented Jun 12, 2014 at 9:24
  • I've placed this code: function mymodule_user_login(&$edit, $account) { drupal_add_js(drupal_get_path('module', 'mymodule') . "/newwindow.js", 'file'); }
    – AgA
    Commented Jun 12, 2014 at 9:48
  • Same code if I place in hook_init then it works.
    – AgA
    Commented Jun 12, 2014 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.