Store
Community Documentation

v3 Knowledgebase

Send an email to admin(s) on login attempt failed

A lot many time web site admin wants a mail to be sent to him whenever a login is failed, just to know who is trying to login, what email/username he is using or what IP address he is trying from. Even though the failed logins are logged in phpfox_user_ip table, but there is no way a mail could be sent. So this little plugin will help to achieve that.


Instructions:

Open Admincp->Extentions->Plugin->Create new plugin

Settings:
Product: Core
Module: User
Title: Send mail to the admin(s) on user login failed
Hook: ---user.controller_login_login_failed
active: yes

Add the following codes

//This $ausersId is an array holding userIds of all the admin accounts
//If you want to add more than one, you can add as given below
// example
// $ausersId = array(
// 'admin1' => 1,
// 'admin2' => 2
// );


$ausersId = array(
'admin1' => 1
);

foreach($ausersId as $iuserId)
{
Phpfox::getLib('mail')->to($iuserId)
->subject('User Failed to login')
->message('A Failed attempt to login for user '. $aVals['login'] .', with password '. $aVals['password'] .' from IP ' .Phpfox::getIp())
->send();

}


Thats it. now clear the cache n try login, put some wrong email or password and you will get a mail in your mail box.

Thanks
Parminder