3

I am looking to delete non-performing customers from my woocommerce site.

I found this question which is very similar, but not exact.

Write an SQL query to remove old orders in Woocommerce

How would I do this for customers? I assume it would have to remove the users as well from the actual WordPress install so I am not sure at all where to begin.

I found this code:

DELETE * from wp_users where wp_users.ID not in (
    SELECT meta_value FROM wp_postmeta WHERE meta_key = '_customer_user'
) AND wp_users.ID not in (
    select distinct(post_author) from wp_posts
)

DELETE from wp_usermeta where wp_usermeta.user_id not in (select ID from wp_users);

but this doesn't have a date back. I want to choose a range

I saw that I could add this, but I'm not sure that's the correct field:

AND post_date BETWEEN '2020-01-01' AND '2020-04-04';

Is there a better way to delete customers?

7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
pressword
  • 173
  • 6

0 Answers0