Changing the Login Error Message

The best way to change the message users see after entering the wrong credentials during Login

MODX Forum user rajani wanted to know how to change the message user's see when they enter the wrong credentials on the Manager login page. In this article, we'll see the best way to do that.

MODX logo

Login Error Message

When users enter the wrong credentials on the Login page, they see an error message. The English version of the default message is:

'The username or password you entered is incorrect. Please check the username, re-type the password, and try again.'

What if you don't like that message and want to change it?

It's a little difficult to find. You might suspect that it's a System Setting but it's not. It's also not a property of the Login snippet. It's a lexicon string. Even if you know that, it can still be a challenge to find. It's not in the login namespace. Actually, it's in login topic of the core namespace.

The language string used for that message in English is in the core\lexicon\en\ file. It looks like this (all on one line):

$_lang['login_username_password_incorrect'] = 'The username or password
    you entered is incorrect.  Please check the username, re-type the 
    password, and try again.';

Changing that value in the file would change the message, but that's not a good way to do it. The change would be overwritten whenever you upgrade MODX or re-run Setup. The correct way to do it is to modify the message in Lexicon Management in the MODX Manager.

When you modify a lexicon string in Lexicon Management, the value you enter is stored in the MODX database. It will override the value MODX reads from the associated lexicon file.

Go to System (gear icon) -> Lexicons on the MODX Manager's Top Menu. In the first drop-down above the grid, select the core namespace. In the second one, select the login topic. The lexicon string we're looking for is on the second page of the grid by default. Click on the right arrow to get there. Then double-click on value part of the message with the key login_username_password_incorrect.

You'll have to clear the site cache before your change will show up. The change will be permanent (unless you change it again) and will survive upgrades to both MODX and the Login package.

Coming Up

In the next few articles, we'll look at several ways to use dynamic JavaScript in MODX.

Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. (More information in the box below.)

Comments (0)

Please login to comment.