Blog Featured User Log

WordPress does not keep the log of user activity out of the box. There are plenty of third-party plugins that do it. However, if you need to get a list of all users that have successfully logged in into a WordPress installation at least once then a MySQL query below can do that for you:

SELECT wp_users.user_login FROM `wp_users`, `wp_usermeta` WHERE `wp_usermeta`.`user_id` = `wp_users`.ID AND `wp_usermeta`.`meta_key` = 'session_tokens';

The query above relies on the session data that is saved in the database once a user logs in. If the user has never logged in they won’t have any session data saved against their user id and that user won’t be returned by the query.

Anton Zaroutski

WordPress Specialist, Front End and PHP Developer, @xeiter

Leave a Reply

Your email address will not be published. Required fields are marked *