• Is there a way to delete all users in bulk (ten tousands) who did not log in in the last 6 months and has no comments?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Here’s a plugin that looks like it’ll do the job: https://wordpress.org/plugins/inactive-user-deleter/

    I recommend making a backup before doing anything with mass deletes. BackWPup is a good plugin for that: https://wordpress.org/plugins/backwpup/

    Thread Starter teszter

    (@teszter)

    Thx, but this is too simple and toooo old to be good 🙂

    Some sql query magic would be better.

    There is a one simple question. How do you know that some user “did not log in in the last 6 months”? There is no magic DB query.

    Thread Starter teszter

    (@teszter)

    I think Buddypress records the last login date, because on the profil page it shows “last active: …date”

    You asked about Buddypress on the WordPress support forum? 🙂
    Anyway, “last active: …date” means some user made some activity like posting or commenting. But this activity doesn’t mean user login/logout. Date takes from date of users post or comment. However, you can delete users, which didn’t create any records in the posts table.

    Thread Starter teszter

    (@teszter)

    Since it is a WordPress plugin… nevermind.

    “Date takes from date of users post or comment.”

    Thx, I didn’t know how that works.

    I don’t want to delete someone just because they didn’t post anything yet. It would affect members who has just registered anyway.

    I’ve found a way to record the last login dates, but now I have to run this code for 6 months ’till I can tell who is inactive…

    There is some trick for WP 4.0 or above. Since this version WP adds sessions tokens into the usermeta table when someone logs in to the site. What version of WP do you have? How long have you been using it?

    Thread Starter teszter

    (@teszter)

    “What version of WP do you have?”
    Always the latest of course. 🙂

    “WP adds sessions tokens into the usermeta table when someone logs in to the site”
    Thx I think this is going to lead somewhere finally…
    https://developer.wordpress.org/reference/classes/wp_user_meta_session_tokens/get_sessions/

    You must JOIN wp_users and wp_usermeta table and filter out rows by user_registered field with Date you need and plus non exists sessions_tokens in the usermeta table. That will be list of users, which you can kill.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Delete inactive users’ is closed to new replies.