Question

I'm trying to delete users that are older than a certain date in wordpress.

Locally this works (but not on production server where the mysql is newer).

SELECT ID FROM `wp_users` WHERE user_registered < 20131201

The user_registered is a datetime-field. A field could look like this: 2013-12-10 21:20:12

Is this above way it's supposed to be done? Or is there a better solution? I'm asking because I'm getting results that isn't really satisfactory.

Was it helpful?

Solution

I think the date format you use is the issue, try this :

SELECT ID FROM `wp_users` WHERE user_registered < '2013-12-01'

OTHER TIPS

DELETE FROM `wp_users` WHERE user_registered < str_to_date('20131201', '%Y/%m/%d')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top