Remove Authors with no Posts WordPress Plugin


Remove all registered wordpress users on the blog that do not have any post associated with them.

Drop this in a file, name it something like delete-non-authors.php, upload it to your plugins folder, activate, and you’re done! (You can then de-activate).


 * Plugin Name: Delete Non Authors

function delete_non_authors()
    global $wpdb;
    $non_authors = $wpdb->get_col(
        "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users
        LEFT JOIN $wpdb->posts ON $wpdb->users.ID = $wpdb->posts.post_author
        WHERE $wpdb->posts.ID IS NULL"

    foreach ($non_authors as $user_ID)
register_activation_hook(__FILE__, 'delete_non_authors');


Share please!

Some of the links on this site are affiliate links. This means if you click on the link and purchase the item, I will receive an affiliate commission.

Leave a Reply