WordPress Tips and Tricks
WordPress MultiSite add new user and skip confirmation email
When working in a WordPress MultiSite Network, users with Admin/Editor level access can create new users if enabled but they lack the “Skip Confirmation Email” toggle that Super Admins have which allows them to add the user without sending an email that requires their confirmation.
In order to give regular WordPress Admin/Editor users this same ability we came up with a simple workaround for WordPress Network installs.
1. We added an action to hook into the “user_new_form” function. In this function we mimic the “Skip Confirmation Email” toggle that appears for Super Admins.
function wnet_custom_user_profile_fields($user){ if (!is_super_admin( $user_id )) { ?> <table class="form-table"> <tr> <th scope="row"><?php _e('Skip Confirmation Email') ?></th> <td><input type="checkbox" name="noconfirmation" value="1" <?php checked( $_POST['noconfirmation'], 1 ); ?> /> Add the user without sending an email that requires their confirmation.</td> </tr> </table> <?php } } add_action( "user_new_form", "wnet_custom_user_profile_fields" );
2. We need to add a filter to the “wpmu_signup_user_notification” function. This function checks for the above “noconfirmation” toggle and activates the new user without needing the email confirmation.
add_filter('wpmu_signup_user_notification', 'wnet_auto_activate_users', 10, 4); function wnet_auto_activate_users($user, $user_email, $key, $meta){ if(!current_user_can('manage_options')) return false; if (!empty($_POST['noconfirmation']) && $_POST['noconfirmation'] == 1) { wpmu_activate_signup($key); return false; } }
It’s debatable whether or not this should be a WordPress Core option but we definitely don’t like to open up our WordPress Networks by giving Super Admin access to everyone who requires this ability.
Note: After adding a new user you’ll still see this message on screen but you can ignore it.
Download on the WordPress Plugin Directory.