I need to create a plugin that displays a popup when an user makes a log in on my Joomla 3.6.4 website. I know that I need to create a Plugin and trigger the onUserAfterLogin event, but I don't know how to create HTML and Javascript from inside a Plugin. So, my popuplogin.xml is:

    <?xml version="1.0" encoding="utf-8"?>
<extension version="3.6" type="plugin" group="user" method="upgrade">
        <license>GNU General Public License</license>
        <description>Plugin to display a modal after UserLogin</description>
                <filename plugin="popuplogin">popuplogin.php</filename>

And my popuplogin.php is:


// no direct access
defined('_JEXEC') or die;

class PlgUserPopuplogin extends JPlugin
    public function onUserAfterLogin($options)
              return 'I think I need to place Javascript/HTML here';


With these files, nothing happens, even if I place a simple <p>I am the login popup</p> inside return. Can you please explain to me how can I properly display a message using a Plugin in Joomla?

  • Silly question, but have you enabled the plugin?
    – Lodder
    Commented Mar 8, 2018 at 12:21
  • 1
    silly question, but why are you still on J 3.6 when updating to current 3.8 is so easy and painless?
    – Simba
    Commented Mar 8, 2018 at 12:26

1 Answer 1


The return value of onUserAfterLogin() should be a boolean -- ie true or false. The idea is that you can use this event handler to do additional validation on the login, so if you return false, it indicates that the login should be rejected.

What you want to do is quite different; you're trying to add content to the page after login. There's several ways of doing this.

  • Option 1: If you're not worried about a modal, you could just use Joomla's message system to tell the user something:

    JError::raiseNotice(100, "Put whatever message you want to tell the user here.");
  • Option 2: Use an extension like Regular Labs Modals, so that you can pop up a modal alert with minimum code. You'd probably not need much more than a single line in your existing plugin to call the modal with the message you want to show.

  • Option 3: Write the modal yourself using JavaScript, and inject it into the page using addScript() or addScriptDeclaration(), as described in the Joomla documentation here: https://docs.joomla.org/Adding_JavaScript

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.