- Author:Scott Reilly
- Last update:16 April 2008
- Compatibility:WP 2.2+, 2.3+ and 2.5+
- Comments:go here
- Download:[ zip ]
Logs the dates and IP addresses of successful user logins and failed login attempts.
- Records the IP address and date and time of the last successful login for each user account.
- Records the IP address and date and time of the most recent failed login for each user account, as well as a count of total number of failed logins since the last successful login.
- Adds the submenu ‘Last Logins’ under the ‘Users’ admin menu which displays a table of the last login and bad logins data recorded for all user accounts.
- Adds the template tags
bad_logins()that can be inserted in theme templates to display information regarding the logged-in users last login or bad login attempts since last login, respectively.
- Each template tag allows for default information display, or can be passed a custom format string that will be parsed for percent-tag substitution.
- Last login information, and bad logins since last login (if any had occurred), is summarized in the upper-right corner of the WP Admin pages. (This feature is not compatible with the Hello Dolly plugin, or any of its knockoffs).
A screenshot of the admin header showing the last successful login as well as failed login attempts.
A screenshot of the admin header showing the last successful login when there hasn’t been failed login attempts.
A screenshot of the ‘Last Logins’ submenu admin page under ‘Users’. This page presents the log of successful and failed logins.
- Download the file last-logins.zip and unzip it into your wp-content/plugins/ directory.
- Activate the plugin through the ‘Plugins’ admin menu in WordPress.
- (optional) If you wish, you can insert function call(s) to your templates to display information about the last login and/or bad login attempts since the last successful login
Note: users of versions of WordPress older than WP 2.2 may need to perform these additional steps:
- Go to the admin ‘Users’ page and click the new ‘Last Logins’ submenu link
- Press the ‘Install’ button to create the database table needed for the plugin to work
<?php function last_login($custom_message = '', $if_none = '') ?>
This displays information regarding the last login for the currently logged in user.
<?php function bad_logins($custom_message = '', $if_none = '') ?>
This displays information regarding failed login attempts for the currently logged in user.
Optional argument. This is a string to be output instead of the default string. Use ‘%date%’, ‘%ip%’, (and only for
bad_logins(): ‘%count%’) to indicate where those respective pieces of information should be substituted by the functions.
Optional argument. This is a string to be output when the requested information is not available (the user hasn’t had a login recorded yet, or there haven’t been any failed
<?php last_login(); ?>
«Your last successful login was at 2008-01-08 14:32:21 from 127.0.0.1.»
<?php bad_logins(); ?>
«There have been 2 bad login attempts for your account since your last successful login. Last failed login at 2008-01-08 12:12:03 from 127.0.0.1.»
<?php last_login('Last logged in at %date% from %ip%'); ?>
«Last logged in at 2008-01-14:32:21 from 127.0.0.1»
<?php bad_logins('%count% failed logins -- latest from %ip% at %date%.'); ?>
«2 failed logins — latest from 127.0.0.1 at 2008-01-08 12:12:03»
Frequently Asked Questions
Q: Does this plugin retain EVERY successful login and failed login attempt?
A: No. In the future it likely will, but at the moment it only retains information about the two most recent logins for each user, and the two most recent failed login attempts. It does retain a count of how many failed logins were attempted for each user account since the last successful login by that user. However, the count is reset once the user successfully logs in.
Q: Does this plugin do anything with login and/or failed login attempt information other than logging and report?
A: Not at this time. In the future, it may harness the information it collects to do things like throttle IP addresses and/or user accounts after a certain number of failed logins, among other possible things.
Q: I (or my visitor(s)) have been to the site more recently than the last login indicates; what gives?!
A: Bear in mind that the plugin only logs *logins*. If a user never logs out and/or never ends their browser session, they can effectively remain logged in indefinitely. The plugin only tracks logins, not site access.
Q: Why does the bad login count get reset back to 0?
A: The count of bad logins (as well as the information regarding the most recent failed login attempt) is only retained through the next successful login. In a later version, this plugin will retain all login and failed login attempt logs indefinitely.
- 16 Apr 2008 : v1.0 — Release notes.
Copyright & DisclaimerCopyright © 2007-2008 by Scott Reilly (aka coffee2code)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the «Software»), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Thanks to all those who have contributed feedback and support!