Show a Welcome Message on First Login in Joomla

Greet every new member or administrator with a message they see once, right after their first login to your Joomla site, using one PHP snippet.

Show a Welcome Message on First Login in Joomla
Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

A new member logs in for the first time and sees the same page as everyone else: no welcome, no nudge to fill in their profile, no hint about where to start. A new editor opening the administrator gets Joomla's dashboard and nothing else. Joomla has no setting for a message that shows once, on the first login. You can add one to your Joomla site, the administrator, or both with one PHP snippet in Code Snippets.

The PHP snippet code

The snippet waits for a successful login, checks whether the user has ever logged in before, and queues a message that Joomla shows on the page the user lands on.

use Joomla\CMS\Factory;

// The message a user sees right after logging in for the first time.
$message = 'Welcome aboard! Take a minute to complete your profile.';

// info, success, warning or error. It sets the color of the message box.
$type = 'info';

// Do not edit below.

$app = Factory::getApplication();

$app->registerEvent('onUserAfterLogin', function ($event) use ($app, $message, $type)
{
    // Joomla 5 names the event arguments. Joomla 4 passes them by position.
    $arguments = $event->getArguments();
    $options   = $arguments['options'] ?? $arguments[0] ?? [];
    $user      = $options['user'] ?? null;

    if (!$user || empty($user->id))
    {
        return;
    }

    // Joomla stamps the last visit date in the database during the login, but
    // this user object still holds the value from before it: empty on a first
    // login. Sites migrated from Joomla 3 may hold a zero date instead.
    $lastVisit = (string) ($user->lastvisitDate ?? '');

    if ($lastVisit !== '' && strpos($lastVisit, '0000-00-00') !== 0)
    {
        return;
    }

    $app->enqueueMessage($message, $type);
});

Edit $message to say what you want. $type picks the color of the message box: info is blue, success green, warning yellow and error red.

Joomla records the date of each user's last visit. During the login it stamps the new date in the database, but the user object it passes to the snippet still holds the old value, which is empty for a first login. That is what the snippet checks, so no extra storage is needed and the message shows exactly once per account. Accounts imported from Joomla 3 may hold a zero date instead of an empty one, and the snippet treats those as first logins too.

How to add this snippet

  1. Install Code Snippets if it isn't installed already.
  2. Log into your Joomla backend.
  3. Go to Components → Tassos Code Snippets.
  4. Click New.
  5. Enter a title, for example First login message.
  6. Set Code Type to PHP.
  7. Set Insertion Method to Auto-Insert Locations.
  8. Set Location to where the message should appear:

    • Site Page Load for logins on the frontend of your site.
    • Admin Page Load for logins to the Joomla administrator (Pro).
    • Site and Admin Page Load for both (Pro).
  9. Paste the code above into the editor.
  10. Leave Access set to Public. The login request comes from a visitor who isn't logged in yet, and the snippet only runs for that visitor when it's public.
  11. Click Save & Close.

Every user sees the message, whatever their group. To greet one group only, open the Conditional Logic tab and add a User Group condition. Learn more in Conditional Logic.

Check that it works

  1. Create a new user in Users → Manage, or use an account that has never logged in.
  2. Log in with that user in a private browser window, on the site or in the administrator, depending on the location you chose.

The message shows at the top of the first page after the login. Log out and log in again, and it's gone. Users who have logged in before never see it.

To send each user group to its own page after login, see Redirect Users After Login by User Group in Joomla. To learn more about how PHP snippets work, read the PHP snippet docs.

Last updated on Oct 19th 2026 10:10