a plugin of mine stores user-specific settings in the usermeta table. If the plugin is uninstalled, I would like to delete this setting for all users. How is the right way to remove the settings for all users in the database? I found the function delete_usermeta, but this requires a UserID, so I would have to first determine all users and then go into a loop over it.
What should I consider in the context of a MU installation?
You could use $wpdb->query() to run a delete query of all records with your particular meta_key. I don’t know if this is the “right” way. It gets away from the need to loop through user IDs, but it can be very dangerous, there is no undo query. 🙂 If there is some accidental name collision, you could wreak havoc.
There is no difference in usermeta tables between regular and MU versions, so there are no additional considerations I can see.
You probably know this, but it’s worth noting, this should only be done on an uninstall hook, NOT the deactivation hook, and that it’s very clear to the user that uninstalling will forever delete these settings with no chance of recovery except by restoring the DB from an earlier backup.