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’);



Recommended For You

About the Author: staff

Leave a Reply

Your email address will not be published.