This works:
in the include.php file for your module (I called this one xxAutojs you could call yours anything)
function xxAutojs_meta(){
$_tmp = array(
'name' => 'Auto Js',
'url' => 'autojs',
'version' => '1.0.0',
'developer' => 'The Jamroom Network, ©' . strftime('%Y'),
'description' => 'Trigger javascript after a user logs in',
'category' => 'custom',
'license' => 'mpl'
);
return $_tmp;
}
function xxAutojs_init(){
jrCore_register_event_listener('jrUser', 'login_success', 'xxAutojs_login_success_listener');
jrCore_register_event_listener('jrCore', 'profile_template', 'xxAutojs_profile_template_listener');
return true;
}
function xxAutojs_profile_template_listener($_data, $_user, $_conf, $_args, $event)
{
$onLoginJs = jrCore_get_temp_value('xxAutojs', 'login_success_' . $_user['_user_id']);
if ($onLoginJs) {
jrCore_create_page_element('javascript_ready_function', $onLoginJs);
jrCore_delete_temp_value('xxAutojs', 'login_success_' . $_user['_user_id']);
}
}
function xxAutojs_login_success_listener($_data, $_user, $_conf, $_args, $event)
{
$_aJS = array("alert('TEST: Alert On SignIn');");
jrCore_set_temp_value('xxAutojs', 'login_success_' . $_user['_user_id'], $_aJS);
return $_data;
}
The concept:
* when the user logs in a temp value is set for them using their _user_id
* they are redirected to their profile
* when a profile view is viewed, the 'profile_template' listener fires and checks if there is a temp value set for this user, if there is fire the javascript.
* after the javascript has been fired, delete the temp value so the javascript isnt fired again.
If you're redirecting anywhere after the login, then you'd need to choose a listener that exists at that location to listen for the temp value.
You could either set the javascript to be fired at the 'login_success' stage, or just put a TRUE flag there and put all the javascript into the 'profile_template' function.
Your choice.