How to bulk activate all users on an existing site

A question that comes up from time to time is how to implement moderated registration on an existing site with current users.  There is no difference between an “existing” user and a “new” user – they are all simply “users,” so there isn’t a way for the plugin to know who you want to activate and who you don’t.

One particular problem, though, is that when you activate a user it will send the user a notification that they have been activated and if current settings are to send the user their initial password, their password will be set upon activation (thus changing an existing user’s password if you activate them).  

Here is a utility script available that allows you to set all users as activated.  It is a copy/paste code snippet and it will add an admin screen to set every user on the site as activated without sending the user email and without affecting their password. (If you’re not sure how to use code snippets, see: How to use code snippets from the site.)

This adds a menu item under the Tools menu – Activate All Users.  Go to that screen, check the confirmation box and click submit. All users will be set to active at that point.  After you complete the process you can optionally remove the code snippet.

The Code:

[snippet slug=set-all-site-users-as-active lang=php]