<?php
/**
* 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)
wp_delete_user($user_ID);
}
register_activation_hook(__FILE__, \'delete_non_authors\');
?>
将其放入文件中,命名如下
delete-non-authors.php
, 上传到你的插件文件夹,激活,你就完成了!(然后可以取消激活)。