Removing users from db who don't have posts or comments (4 posts)

  1. Ted
    Posted 6 years ago #

    I need to create a query that will remove users from our db who don't have any posts or comments. The short of it is that we migrated a custom built blog to WordPress a few months ago, but the custom built blog had users who never actually posted anything. I'm finding now, that because of the large # of users in the database (over 15K, of which less than 500 have actually ever blogged/commented), WordPress is running out of memory a lot, and it's proving a headache.

    I've got the current query to identify the users who haven't posted:

    SELECT wp_users.id, wp_users.user_login FROM wp_users
    LEFT JOIN wp_posts ON wp_users.id=wp_posts.post_author
    WHERE post_author is NULL

    .. but I need to include a check to see if they've commented, and if I could do the delete in the same query that would be great.

    Any ideas?

  2. Robert Chapin
    Posted 6 years ago #

    If you're into code hacks, you could try implementing the users.php overhaul I wrote for version 3.0.


    Be sure to see also http://core.trac.wordpress.org/ticket/12555

  3. Ted
    Posted 6 years ago #

    Thanks for the suggestion, but I'd rather not have to implement a hack for something I should be able to tackle once and be done with it.

  4. ryanmc
    Posted 6 years ago #

    I just ran across this plugin and I am currently testing it. Seems to work ok, but I am adding some functionality so it does more for me. http://www.dagondesign.com/articles/clean-up-users-plugin-for-wordpress/

Topic Closed

This topic has been closed to new replies.

About this Topic