-
-
- Submit Updated Articles to Bing and Yandex with IndexNow in Joomla
- Add Published and Modified Date Meta Tags to Joomla
- Add Open Graph and Twitter Card Tags to Joomla
- Auto-Generate Meta Descriptions from Article Text in Joomla
- Add Noindex to Specific Pages in Joomla
- Verify Your Joomla Site with Google Search Console
-
- Add a View as Markdown Link to Joomla Articles
- Display the Last Modified Date in Joomla Articles
- Embed Iframes in Joomla
- Automatically Link Twitter (X) @mentions in Joomla Articles
- Open External Links in a New Tab in Joomla
- Display Estimated Reading Time in Joomla Articles
- Replace Old URLs in Joomla
- Search and Replace in Joomla
-
- Add a Footer Line to the Joomla Administrator
- Show a Staging Banner in the Joomla Administrator
- Remove the "All" Option from Admin List Limits in Joomla
- Add a Cookie Consent Banner to Joomla
- Make the Administrator Navigation Sticky in Joomla
- Add Google Fonts to Joomla
- Add a Facebook Messenger Chat Button to Joomla
- Add a Reading Progress Bar to Joomla
- Add a Custom Scrollbar to Joomla
- Show Confetti on a Thank You Page in Joomla
- Add Smooth Scrolling to Joomla
- Add a Back to Top Button in Joomla
- Add a WhatsApp Chat Button in Joomla
-
- Protect the Administrator with a Secret URL Key in Joomla
- Show a Welcome Message on First Login in Joomla
- Log Out Idle Administrators in Joomla
- Assign New Users to a Different User Group Automatically in Joomla
- Redirect Visitors by Country in Joomla
- Redirect Users After Login by User Group in Joomla
- Block User Registration with Certain Usernames in Joomla
- Block User Registration by Country in Joomla
- Block User Registration by Email Address in Joomla
- Block User Registration by IP Address in Joomla
- Remove the Forgot Password and Username Links in Joomla
- Remove the Generator Meta Tag in Joomla
- Let Users Log In with Their Email Address in Joomla
- Block Traffic by Country in Joomla
- Block Bot Traffic in Joomla
- Block Traffic by IP Address in Joomla
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.
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
- Install Code Snippets if it isn't installed already.
- Log into your Joomla backend.
- Go to Components → Tassos Code Snippets.
- Click New.
- Enter a title, for example First login message.
- Set Code Type to PHP.
- Set Insertion Method to Auto-Insert Locations.
-
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).
- Paste the code above into the editor.
- 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.
- 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
- Create a new user in Users → Manage, or use an account that has never logged in.
- 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.