I would like to add some additional checks into my wordpress website's username and password authentication function for specific usernames, but I cannot find the correct php file...

/* I would like to do something like this */
if ($username == "testuser_with_no_rights") {
    /* ... */
else { 
    /* do everything as it was defined originally */ 

So, basically, where is the php file, that does the checks for login information?

It is also possible, that there is a much better way of doing this. If that is the case, I am open for suggestions too.

  • 1
    start with looking into wp-login.php – majick Jun 6 '16 at 19:15

You don't want to be messing around with that. Look at the following hook: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login

You should do something like:

function check_test_user() {
// Your code here

add_action('wp_login', 'check_test_user');

The hook will run as part of the Login process and saves you modifying core Wordpress files.

| improve this answer | |
  • you first sentence is just not correct, that is not the file in which the authentication is actually done – Mark Kaplun Jun 6 '16 at 19:55
  • Cheers Mark - I deleted it and left the rest. – TomC Jun 6 '16 at 19:56
  • 1
    now looking better the other part is also problemattic, wp_login is "called" after the user was authenticated. wp_authenticate (or some hokk in it) is probably the one you were thinking of. – Mark Kaplun Jun 6 '16 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.