Last active
December 2, 2020 16:41
-
-
Save decodist/10e548a5ea915381f5b3b1062cd3ed1f to your computer and use it in GitHub Desktop.
Find Wordpress users who have logged in at some point, but not within the past year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT u.id, u.user_login, u.user_email, u.user_registered, | |
from_unixtime( | |
trim( trailing ';}}' from | |
RIGHT( | |
um.meta_value, | |
(LENGTH(um.meta_value) - LOCATE('login',um.meta_value) - 8) | |
) | |
) | |
,'%Y-%m-%d') as last_login | |
FROM wp_users u, wp_usermeta um | |
WHERE um.user_id = u.id | |
AND um.meta_key = 'session_tokens' | |
HAVING last_login < DATE_SUB(NOW(),INTERVAL 1 YEAR) | |
ORDER BY last_login DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment