If a plugin stores data in the usermeta tables what is the best practice method to delete these entries for all users in uninstall.php? I could access the database directly but is there another way?
Tell me more
×
WordPress Answers is a question and answer site for
WordPress developers and administrators. It's 100% free, no registration required.
|
|
It's best not to interact with the database directly, especially when issuing DELETE statements, since a single typo can destroy unintended data. Instead, use WordPress functions to get a list of all user IDs, then remove the user meta field for each user individually, like so:
Function reference: http://codex.wordpress.org/Function_Reference/get_users http://codex.wordpress.org/Function_Reference/delete_user_meta |
|||
|
|
|
Best practice is to prefix the meta data your plugin enters that way you can simply do something like a search for all meta_key's like this
|
|||
|
|