I customize joomla registration module by adding some extra fields. If registration succeeds, I need to call some javascript code. So I changed the registration controller file (components/com_users/controllers/registration.php) like:
public function register()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
...
// Attempt to save the data.
$return = $model->register($data);
if ($return === true) {
$script = "<Here comes javascript code>";
echo $script; // this doesn't work
// I don't know how to call above script
...
}
...
}
The echo doesn't work here and I found that joomla needs to use its api like "$document->addScriptDeclaration($script);" But this code needs to be running on view, not on controller.
Have any thoughts? Thanks in Advance.