Lewis' Blog Tales from the trenches of information technology


Mass editing users in WordPress

Download PDF


A thousand apologies to those of you who have received email notifications of my last post, which added two new categories to the blog. Following up on an enhancement request from a long-time friend to provide email notifications of new posts, I installed the Subscribe2 plugin. Not fully understanding the ramifications of setting "Option for Registered Users to auto-subscribe to new categories is checked by default" to "Yes," I set that, which automatically enabled all existing users as subscribers to newly-created categories, even if they were not subscribed to any categories previously (my reading of this option was that only new registrants would be auto-subscribed to new categories, thus saving them click-time during setup).

When I saw the flood of bounce messages come back to me upon posting my previous entry (a separate issue with which I must deal at some point in the near future), I knew I had a bit of a problem. Again, to all of you who do not want email notifications, my sincere apologies.

I found, however, that merely setting the above option to "No" does not undo the previous toggle for those existing users, and the admin panel for Subscribe2 has no option for setting that en masse (I can, however, unsubscribe users who have been subscribed, but the next time I create a new category, they'll get spammed again).

I looked for a mass user edit plugin (figuring that it would be hit or miss, as what would yet another plugin know of the meta data set by Subscribe2?), but could not find anything to fit the need (note to self: consider writing one).

So, time to roll up the sleeves and use some SQL to fix the problem. smiley

Luckily, a little poking at classes/class-s2-core.php yielded the field I needed from the wp_usermeta table (meta_key) would contain s2_autosub. phpMyAdmin quickly revealed that the corresponding meta_value field data would be "yes" (or "no").

So, the quick way to toggle all of the users to "no" was with a brief SQL statement:

UPDATE wp_usermeta SET meta_value = replace(meta_value, "yes", "no") WHERE meta_key = "s2_autosub";


The final step was to go back and toggle the setting back on for the handful of users who I did know wanted to be auto-subscribed (I made a note of those earlier, evident by the number of users subscribed to the new categories vs the number subscribed to other categories).

(This will be the proof of the pudding, as I'm adding new categories here for Databases & MySQL.)

Last Updated on by

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.