{"id":517,"date":"2012-02-17T15:02:05","date_gmt":"2012-02-17T13:02:05","guid":{"rendered":"https:\/\/polyetilen.lt\/?p=517"},"modified":"2023-05-02T10:01:06","modified_gmt":"2023-05-02T07:01:06","slug":"delete-wordpress-users-with-no-posts-by-mysql-query","status":"publish","type":"post","link":"https:\/\/polyetilen.lt\/en\/delete-wordpress-users-with-no-posts-by-mysql-query","title":{"rendered":"Delete WordPress users with no posts by MySQL query"},"content":{"rendered":"<p>Back up your database regularly, and always before any upgrade. This query delete wordpress users (and they meta info) with no posts: <\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n##delete meta info of user with no posts\r\nDELETE FROM wp_usermeta\r\nwhere user_id NOT IN (\r\n\tSELECT post_author\r\n\tFROM wp_posts\r\n\tGROUP BY post_author\r\n);\r\n\r\n##delete user with no posts\r\nDELETE FROM wp_users\r\nwhere ID NOT IN(\r\n\tSELECT post_author\r\n\tFROM wp_posts\r\n\tGROUP BY post_author\r\n);\r\n<\/pre>\n<p>This query select users with no posts:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT u.* \r\nFROM wp_users u\r\nLEFT JOIN wp_posts p ON u.ID = p.post_author\r\nWHERE p.ID IS NULL\r\nGROUP BY u.ID\r\n<\/pre>\n<p>This query select users with no posts and no comments:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT u.* \r\nFROM wp_users u\r\nLEFT JOIN wp_posts p ON u.ID = p.post_author\r\nLEFT JOIN wp_comments c ON u.ID = c.user_id\r\nWHERE p.ID IS NULL AND c.comment_ID IS NULL\r\nGROUP BY u.ID;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Back up your database regularly, and always before any upgrade. This query delete wordpress users (and they meta info) with no posts: ##delete meta info of user with no posts DELETE FROM wp_usermeta where user_id &hellip; <a href=\"https:\/\/polyetilen.lt\/en\/delete-wordpress-users-with-no-posts-by-mysql-query\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"http:\/\/polyetilen.lt\/?p=264","footnotes":""},"categories":[88],"tags":[91,92,89,90],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-irasas","tag-komentaras","tag-naudotojas","tag-trinti","en-US"],"_links":{"self":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/comments?post=517"}],"version-history":[{"count":1,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/517\/revisions"}],"predecessor-version":[{"id":518,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/517\/revisions\/518"}],"wp:attachment":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/media?parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/categories?post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/tags?post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}