For the purposes of this post let’s assume that you’ve setup an instance of WordPress Multisite, there are a handful of sites (termed blogs), you’re the super admin, and there are different administrators per site. What if one of the site administrators wants to add a new user to their site? Easy enough, they can go to Users > Add New and enter a new username and email address and create a new user account. The problem is, since they’re not a super admin, this doesn’t actually create an account but rather merely create a new user signup and send them an invitation via the provided email address. The new user must then click a link within the email to accept the invitation, which actually creates the user account. Worse yet, this invitation email isn’t easily editable within the Network Admin > Settings > Network Settings, but rather only via a WordPress filter hook. This sort of workflow may make sense for a true blog site, but what about a business site where user accounts are used to manage staff bios and the web content manager needs to add or remove dozens of users? This is what I would call a hassle! It may not be the solution for everyone, but one solution is to disable the new user invitation email and automatically activate the new user signup.
The benefit to this is that web content managers no longer need to hassle people to check their email to activate their user account, and as soon as a new user is created the user account will show up in the list of users. Also the person will receive the standard “Welcome User Email” immediately after the new user account is created, which by default includes the username and password needed to login.
Thankfully, due to the power of WordPress filter hooks this is an incredibly easy solution to implement. However, since this is intended to be used across the entire WordPress network it is best to create a Must-Use Plugin, or a regular plugin that is Network Activated.
<?php /* * Plugin Name: Disable User Invitation * Plugin URI: http://laubsterboy.com * Description: Disables WordPress Multisite user invitations by automatically submitting the activation key and preventing the email from sending. * Version: 1.0.0 */ /** * Halts the user signup process (where a user would receive an email to activate their account) * and instead automatically activates the account and sends the user welcome email (template * set in network settings). This was done so that site Administrators could create new user * accounts, at the blog level, and bypass the need for the user to activate the account. * * @since 1.0.0 * * @param string $user The new users username. * @param string $user_email The new users email address. * @param string $key The user activation key, needed to create the user account from the "signup" table * @param array $meta User meta. * @return boolean */ function laubsterboy_signup_user_notification($user, $user_email, $key, $meta) { // Manually activate the newly created user account wpmu_activate_signup($key); // Return false to prevent WordPress from sending the user signup email (which includes the account activation link) return false; } add_filter('wpmu_signup_user_notification', 'laubsterboy_signup_user_notification', 10, 4); ?>
Leave a Reply