├── .gitmodules ├── sql.txt ├── changelog.txt ├── README.md ├── add-new-users-files └── languages │ └── add-new-users.pot └── add-new-users.php /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dash-notice"] 2 | path = dash-notice 3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /sql.txt: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `wp_bulk_add_new_users_queue` ( 2 | `bulk_add_new_users_ID` bigint(20) unsigned NOT NULL auto_increment, 3 | `bulk_add_new_users_site_ID` bigint(20), 4 | `bulk_add_new_users_blog_ID` bigint(20), 5 | `bulk_add_new_users_batch_ID` varchar(255), 6 | `bulk_add_new_users_user_login` varchar(255), 7 | `bulk_add_new_users_user_email` varchar(255), 8 | `bulk_add_new_users_user_password` varchar(255), 9 | `bulk_add_new_users_user_role` varchar(255), 10 | PRIMARY KEY (`bulk_add_new_users_ID`) 11 | ) ENGINE=MyISAM; -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Plugin Name: Add New Users 2 | Author: Andrew Billits, Ulrich Sossou 3 | 4 | Change Log: 5 | ---------------------------------------------------------------------- 6 | ---------------------------------------------------------------------- 7 | 8 | 1.0.8 - 02/19/2017 9 | ---------------------------------------------------------------------- 10 | - Fix: PHP7 compatibility 11 | 12 | 1.0.7 - 05/18/2011 13 | ---------------------------------------------------------------------- 14 | - Fix for Admin vs Super Admin level permissions 15 | 16 | 1.0.6 - 02/24/2011 17 | ---------------------------------------------------------------------- 18 | - Bug fix: nonce not defined during queue processing 19 | - Enhancement: allow admin page access to all users who have edit_users 20 | capability 21 | 22 | 1.0.5 - 02/22/2011 23 | ---------------------------------------------------------------------- 24 | - Enhancement: singlesite support 25 | 26 | 1.0.4 - 02/17/2011 27 | ---------------------------------------------------------------------- 28 | - Fix fatal error with current_user_can 29 | 30 | 1.0.3 - 01/04/2011 31 | ---------------------------------------------------------------------- 32 | - 3.1+ compatibility update. 33 | - Internationalization. 34 | - Security fixes. 35 | 36 | 1.0.2 - 06/01/2010 37 | ---------------------------------------------------------------------- 38 | - 3.0+ compatibility update 39 | 40 | 1.0.1 - 01/05/2010 41 | ---------------------------------------------------------------------- 42 | Now functions properly on non-supporter sites. 43 | 44 | 1.0.0 - 11/19/2009 45 | ---------------------------------------------------------------------- 46 | Initial Release. 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Add New Users 2 | 3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.** 4 | 5 | ## Translations 6 | 7 | Translation files can be found at https://github.com/wpmudev/translations 8 | 9 | ## Add New Users lets you quickly add multiple users to your site without wearing out your mouse clicking "Add New". 10 | 11 | Do you find it frustrating adding new users to your site one-by-one? We do! So we created Add New Users. 12 | 13 | ![Add New Users](https://premium.wpmudev.org/wp-content/uploads/2009/12/add-new-users.jpg) 14 | 15 | Easily add new users in groups of 15 16 | 17 | ### Adding new users is simple 18 | 19 | This plugin has been so popular with Multisite and BuddyPress site owners that we've made it available for single WordPress installs. Create and add new users in bulk batches of 15. Creating and adding new users to a site is now as simple as entering a username, an email address, a password (if you wish) and select the level of access to grant to each user. All new users will receive an email containing their new username, password and login link. 20 | 21 | ### Add Users and Sites Faster 22 | 23 | Do you need to add existing users in batches of up to 15? Give the[Add Existing Users plugin](http://premium.wpmudev.org/project/add-existing-users/) a try. If you want your new users to have their own site we have a tool for that too – [Blog and User Creator](../project/blog-and-user-creator). And, to create hundreds or thousands of sites and users automatically we created [Batch Create](../project/batch-create). 24 | 25 | ## Usage 26 | 27 | Start by reading [Installing plugins](https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/) section in our [comprehensive WordPress and WordPress Multisite Manual](https://premium.wpmudev.org/wpmu-manual/) if you are new to WordPress. 28 | 29 | ### To install: 30 | 31 | 1.  Download the plugin file 2.  Unzip the file into a folder on your hard drive 3.  Upload **/add-new-users/** folder to **/wp-content/plugins/** folder on your site 4.  Login to your admin panel for WordPress or Multisite and activate the plugin: 32 | 33 | * For WordPress Multisite installs - visit **Network Admin -> Plugins** and **Network Activate** the plugin. 34 | * On regular WordPress installs - visit **Plugins** and **Activate** the plugin. 35 | 36 | _Note: If you have an older version of the plugin installed in /mu-plugins/ please delete it._ _ 37 | 38 | ![Network activate plugin](https://premium.wpmudev.org/wp-content/uploads/2011/02/addnew61.jpg) 39 | 40 | _ **That's it! No configuration necessary!** 41 | 42 | ### To use: 43 | 44 | A new menu item called **Add New Users** should appear under the **Users** navigation menu.  It is designed for quickly creating and adding new users to a site in batches of up to 15 users. _Please note:_ 45 | 46 | * The users are immediately added to the site and automatically listed as users on the**Users** page. 47 | * They can only access features in the site’s administration panel based on the role they've been assigned 48 | * Spam filters, especially strict ones for institutional email addresses, often block the emails that the login details.  If unsure use free webmail accounts such as gmail, hotmail that don’t block these invitation emails. 49 | * Use only lowercase letters and numbers, with no spaces, in the username 50 | * The username is what they use to sign into the dashboard and is displayed on posts and comments they write. You can’t change a username,  however you can change what [name is displayed](http://help.edublogs.org/2009/08/25/changing-or-deleting-a-username/). 51 | * It won’t allow you to create several usernames with the same email address because the system resets password based on email address. But you can trick it using the [gmail+ method](http://help.edublogs.org/2009/08/24/2009/08/24/2009/02/27/creating-student-accounts-using-one-gmail-account/) 52 | 53 | **To add the new users, blog administrators simply enter:** 54 | 55 | 1. The username they would like to give them 56 | 2. Their email address 57 | 3. A password for the user (if they want otherwise a random password will be automatically generated) 58 | 4. Assign their role - you can find out more about different [levels of access here](https://premium.wpmudev.org/wpmu-manual/introduction-to-super-admin-user/). 59 | 60 | ![Add new users using Add New Users](https://premium.wpmudev.org/wp-content/uploads/2011/02/addnew64.jpg) 61 | -------------------------------------------------------------------------------- /add-new-users-files/languages/add-new-users.pot: -------------------------------------------------------------------------------- 1 | # Translation of the WordPress plugin Add New Users 1.0.3 by Andrew Billits, Ulrich Sossou. 2 | # Copyright (C) 2011 Andrew Billits, Ulrich Sossou 3 | # This file is distributed under the same license as the Add New Users package. 4 | # FIRST AUTHOR , 2011. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Add New Users 1.0.3\n" 10 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/add-new-users\n" 11 | "POT-Creation-Date: 2011-01-04 14:21+0100\n" 12 | "PO-Revision-Date: 2011-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: add-new-users.php:111 21 | msgid "" 22 | "We have problem finding your '/wp-admin/upgrade-functions.php' and '/wp-" 23 | "admin/includes/upgrade.php'" 24 | msgstr "" 25 | 26 | #: add-new-users.php:201 27 | msgid "You do not have permission to access this page" 28 | msgstr "" 29 | 30 | #: add-new-users.php:223 add-new-users.php:327 31 | msgid "Adding Users..." 32 | msgstr "" 33 | 34 | #: add-new-users.php:230 35 | msgid "Users Added." 36 | msgstr "" 37 | 38 | #: add-new-users.php:271 39 | msgid "Passwords cannot contain spaces" 40 | msgstr "" 41 | 42 | #: add-new-users.php:277 43 | msgid "Passwords may not contain the character \"\\\"." 44 | msgstr "" 45 | 46 | #. #-#-#-#-# add-new-users.pot (Add New Users 1.0.3) #-#-#-#-# 47 | #. Plugin Name of the plugin/theme 48 | #: add-new-users.php:300 add-new-users.php:343 49 | msgid "Add New Users" 50 | msgstr "" 51 | 52 | #: add-new-users.php:301 53 | msgid "Errors were found. Please fix the errors and hit Next." 54 | msgstr "" 55 | 56 | #: add-new-users.php:313 add-new-users.php:360 57 | msgid "Next" 58 | msgstr "" 59 | 60 | #: add-new-users.php:314 61 | msgid "Cancel" 62 | msgstr "" 63 | 64 | #: add-new-users.php:316 add-new-users.php:362 65 | msgid "This may take some time so please be patient." 66 | msgstr "" 67 | 68 | #: add-new-users.php:344 69 | msgid "" 70 | "This tool allows you to create new users on this site and add them to this " 71 | "blog." 72 | msgstr "" 73 | 74 | #: add-new-users.php:345 75 | msgid "" 76 | "To add users that have already been created, please use the Add Users functionality here." 78 | msgstr "" 79 | 80 | #: add-new-users.php:347 81 | msgid "" 82 | "To add the new users simply enter the username you'd like to give them " 83 | "(please choose carefully as it cannot be changed), their email address and - " 84 | "should you so choose - a password for them." 85 | msgstr "" 86 | 87 | #: add-new-users.php:348 88 | msgid "" 89 | "You may also select the level that you wish them to access to the site - you " 90 | "can find out more about different levels of access here." 92 | msgstr "" 93 | 94 | #: add-new-users.php:349 95 | msgid "If you do not enter a password a random one will be generated for them." 96 | msgstr "" 97 | 98 | #: add-new-users.php:350 99 | msgid "" 100 | "All new users will receive an email containing their new username, password " 101 | "and login link." 102 | msgstr "" 103 | 104 | #: add-new-users.php:386 105 | msgid "Username" 106 | msgstr "" 107 | 108 | #: add-new-users.php:389 add-new-users.php:396 109 | msgid "Required" 110 | msgstr "" 111 | 112 | #: add-new-users.php:393 113 | msgid "User Email" 114 | msgstr "" 115 | 116 | #: add-new-users.php:400 117 | msgid "User Password" 118 | msgstr "" 119 | 120 | #: add-new-users.php:403 121 | msgid "" 122 | "If no password is entered here a random password will be generated and " 123 | "emailed to the user" 124 | msgstr "" 125 | 126 | #: add-new-users.php:407 127 | msgid "User Role" 128 | msgstr "" 129 | 130 | #: add-new-users.php:444 131 | msgid "" 132 | "Please install the latest version of our free " 134 | "Update Notifications plugin which helps you stay up-to-date with the " 135 | "most stable, secure versions of WPMU DEV themes and plugins. More information »" 138 | msgstr "" 139 | 140 | #. Plugin URI of the plugin/theme 141 | msgid "http://premium.wpmudev.org/project/add-new-users" 142 | msgstr "" 143 | 144 | #. Description of the plugin/theme 145 | msgid "" 146 | "Allows you to bulk create new users on a site and add them to a blog, " 147 | "including the facility to set their role and password on the new site." 148 | msgstr "" 149 | 150 | #. Author of the plugin/theme 151 | msgid "Andrew Billits, Ulrich Sossou" 152 | msgstr "" 153 | 154 | #. Author URI of the plugin/theme 155 | msgid "http://premium.wpmudev.org" 156 | msgstr "" 157 | -------------------------------------------------------------------------------- /add-new-users.php: -------------------------------------------------------------------------------- 1 | fields = isset( $_GET['fields'] ) ? $_GET['fields'] : ''; 51 | 52 | // default to 15 field sets 53 | if ( $this->fields == '' ) 54 | $this->fields = 15; 55 | 56 | // no more than 50 fields sets 57 | if ( $this->fields > 50 ) 58 | $this->fields = 50; 59 | 60 | // activate or upgrade 61 | if ( isset( $_GET['page'] ) && $_GET['page'] == 'add-new-users' ) 62 | $this->make_current(); 63 | 64 | // add admin menu page 65 | add_action( 'admin_menu', array( &$this, 'plug_pages' ) ); 66 | 67 | // load text domain 68 | if ( defined( 'WPMU_PLUGIN_DIR' ) && file_exists( WPMU_PLUGIN_DIR . '/add-new-users.php' ) ) { 69 | load_muplugin_textdomain( 'add_new_users', 'add-new-users-files/languages' ); 70 | } else { 71 | load_plugin_textdomain( 'add_new_users', false, dirname( plugin_basename( __FILE__ ) ) . '/add-new-users-files/languages' ); 72 | } 73 | } 74 | 75 | /** 76 | * Update database 77 | * 78 | **/ 79 | function make_current() { 80 | // create global database table 81 | $this->global_install(); 82 | 83 | if ( get_site_option( 'add_new_users_version' ) == '' ) 84 | add_site_option( 'add_new_users_version', $this->current_version ); 85 | 86 | if ( get_site_option( 'add_new_users_version' ) !== $this->current_version ) 87 | update_site_option( 'add_new_users_version', $this->current_version ); 88 | 89 | if ( get_option( 'add_new_users_version' ) == '' ) 90 | add_option( 'add_new_users_version', $this->current_version ); 91 | 92 | if ( get_option( 'add_new_users_version' ) !== $this->current_version ) 93 | update_option( 'add_new_users_version', $this->current_version ); 94 | 95 | } 96 | 97 | /** 98 | * Create global database if it doesn't exist 99 | * 100 | **/ 101 | function global_install() { 102 | global $wpdb; 103 | 104 | if( @is_file( ABSPATH . '/wp-admin/includes/upgrade.php' ) ) 105 | include_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); 106 | else 107 | die( __( 'We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'', 'add_new_users' ) ); 108 | 109 | // choose correct table charset and collation 110 | $charset_collate = ''; 111 | if( $wpdb->has_cap( 'collation' ) ) { 112 | if( !empty( $wpdb->charset ) ) { 113 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 114 | } 115 | if( !empty( $wpdb->collate ) ) { 116 | $charset_collate .= " COLLATE $wpdb->collate"; 117 | } 118 | } 119 | 120 | $table = "CREATE TABLE IF NOT EXISTS `{$wpdb->base_prefix}add_new_users_queue` ( 121 | `add_new_users_ID` bigint(20) unsigned NOT NULL auto_increment, 122 | `add_new_users_site_ID` bigint(20), 123 | `add_new_users_blog_ID` bigint(20), 124 | `add_new_users_batch_ID` varchar(255), 125 | `add_new_users_user_login` varchar(255), 126 | `add_new_users_user_email` varchar(255), 127 | `add_new_users_user_password` varchar(255), 128 | `add_new_users_user_role` varchar(255), 129 | PRIMARY KEY (`add_new_users_ID`) 130 | ) $charset_collate;"; 131 | 132 | maybe_create_table( "{$wpdb->base_prefix}add_new_users_queue", $table ); 133 | } 134 | 135 | /** 136 | * Add admin menu 137 | * 138 | **/ 139 | function plug_pages() { 140 | //add_submenu_page( 'users.php', 'Add New Users', 'Add New Users', 'edit_users', 'add-new-users', array( &$this, 'page_output' ) ); 141 | add_submenu_page( 'users.php', 'Add New Users', 'Add New Users', 'add_users', 'add-new-users', array( &$this, 'page_output' ) ); 142 | } 143 | 144 | /** 145 | * Add one row of data to the queue 146 | * 147 | **/ 148 | function queue_insert( $batch_ID, $user_login, $user_email, $user_password, $user_role ) { 149 | global $wpdb; 150 | 151 | $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->base_prefix}add_new_users_queue ( add_new_users_site_ID, add_new_users_blog_ID, add_new_users_batch_ID, add_new_users_user_email, add_new_users_user_role, add_new_users_user_login, add_new_users_user_password ) VALUES ( %d, %d, %d, %s, %s, %s, %s )", $wpdb->siteid, $wpdb->blogid, $batch_ID, $user_email, $user_role, $user_login, $user_password ) ); 152 | } 153 | 154 | /** 155 | * Process queue for one blog 156 | * 157 | **/ 158 | function queue_process( $blog_ID, $site_ID ) { 159 | global $wpdb; 160 | 161 | $query = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}add_new_users_queue WHERE add_new_users_site_ID = '%d' AND add_new_users_blog_ID = '%d' LIMIT 1", $site_ID, $blog_ID ); 162 | 163 | $users = $wpdb->get_results( $query, ARRAY_A ); 164 | 165 | if( count( $users ) > 0 ) { 166 | foreach ( $users as $user ) { 167 | $user['add_new_users_user_password'] = ( 'empty' !== $user['add_new_users_user_password'] ) ? $user['add_new_users_user_password'] : wp_generate_password(); 168 | 169 | if ( is_multisite() ) 170 | $user_id = wpmu_create_user( $user['add_new_users_user_login'], $user['add_new_users_user_password'], $user['add_new_users_user_email'] ); 171 | else 172 | $user_id = wp_create_user( $user['add_new_users_user_login'], $user['add_new_users_user_password'], $user['add_new_users_user_email'] ); 173 | 174 | if ( $user_id && ! is_wp_error( $user_id ) ) { 175 | if ( is_multisite() ) { 176 | add_user_to_blog( $wpdb->blogid, $user_id, $user['add_new_users_user_role'] ); 177 | wpmu_welcome_user_notification( $user_id, $user['add_new_users_user_password'], '' ); 178 | } else { 179 | if ( isset( $user['add_new_users_user_role'] ) ) { 180 | $user_object = new WP_User( $user_id ); 181 | $user_object->set_role( $user['add_new_users_user_role'] ); 182 | } 183 | wp_new_user_notification( $user_id, $user['add_new_users_user_password'] ); 184 | } 185 | 186 | $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}add_new_users_queue WHERE add_new_users_blog_ID = '%d' AND add_new_users_site_ID = '%d' AND add_new_users_ID = '%d'", $wpdb->blogid, $wpdb->siteid, $user['add_new_users_ID'] ) ); 187 | } 188 | } 189 | } 190 | } 191 | 192 | /** 193 | * Check if current blog is a supporter blog 194 | * 195 | **/ 196 | function is_supporter() { 197 | if ( function_exists( 'is_supporter' ) ) 198 | return is_supporter(); 199 | 200 | return false; 201 | } 202 | 203 | /** 204 | * Validate user login and email 205 | * 206 | **/ 207 | function validate_user_signup( $user_login, $user_email ) { 208 | if ( is_multisite() ) { 209 | return wpmu_validate_user_signup( $user_login, $user_email ); 210 | } else { 211 | $errors = new WP_Error(); 212 | 213 | $sanitized_user_login = sanitize_user( $user_login ); 214 | $user_email = apply_filters( 'user_registration_email', $user_email ); 215 | 216 | // Check the username 217 | if ( $sanitized_user_login == '' ) { 218 | $errors->add( 'empty_username', __( 'ERROR: Please enter a username.' ) ); 219 | } elseif ( ! validate_username( $user_login ) ) { 220 | $errors->add( 'invalid_username', __( 'ERROR: This username is invalid because it uses illegal characters. Please enter a valid username.' ) ); 221 | $sanitized_user_login = ''; 222 | } elseif ( username_exists( $sanitized_user_login ) ) { 223 | $errors->add( 'username_exists', __( 'ERROR: This username is already registered, please choose another one.' ) ); 224 | } 225 | 226 | // Check the e-mail address 227 | if ( $user_email == '' ) { 228 | $errors->add( 'empty_email', __( 'ERROR: Please type your e-mail address.' ) ); 229 | } elseif ( ! is_email( $user_email ) ) { 230 | $errors->add( 'invalid_email', __( 'ERROR: The email address isn’t correct.' ) ); 231 | $user_email = ''; 232 | } elseif ( email_exists( $user_email ) ) { 233 | $errors->add( 'email_exists', __( 'ERROR: This email is already registered, please choose another one.' ) ); 234 | } 235 | 236 | do_action( 'register_post', $sanitized_user_login, $user_email, $errors ); 237 | 238 | $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 239 | 240 | return array( 'user_name' => $sanitized_user_login, 'orig_username' => $user_login, 'user_email' => $user_email, 'errors' => $errors ); 241 | } 242 | } 243 | 244 | /** 245 | * Display plugin admin page 246 | * 247 | **/ 248 | function page_output() { 249 | global $wpdb; 250 | 251 | // display error message if supporter only 252 | if ( !$this->is_supporter() && 'yes' == $this->supporter_only ) { 253 | supporter_feature_notice(); 254 | return; 255 | } 256 | 257 | // display message when successful 258 | if( isset( $_GET['updated'] ) ) 259 | echo '

' . urldecode( $_GET['updatedmsg'] ) . '

'; 260 | 261 | echo '
'; 262 | 263 | $action = isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : ''; 264 | switch( $action ) { 265 | 266 | case 'process_queue': // process queue from database 267 | check_admin_referer( 'add-new-users-process_queue_new_users' ); 268 | 269 | echo '

' . __( 'Adding Users...', 'add_new_users' ) . '

'; 270 | $this->queue_process( $wpdb->blogid, $wpdb->siteid ); 271 | $queue_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}add_new_users_queue WHERE add_new_users_site_ID = '%d' AND add_new_users_blog_ID = '%d'", $wpdb->siteid, $wpdb->blogid ) ); 272 | 273 | if ( $queue_count > 0 ) 274 | echo ''; 275 | else 276 | echo ''; 277 | break; 278 | 279 | case 'process': // add entries to queue 280 | if ( isset( $_POST['Cancel'] ) ) 281 | echo ""; 282 | 283 | $batch_ID = md5( $wpdb->blogid . time() . '0420i203zm' ); 284 | $errors = ''; 285 | $error_fields = array(); 286 | $error_messages = ''; 287 | $global_errors = 0; 288 | $add_new_users_items = array(); 289 | 290 | // validate users names, emails and passwords 291 | for ( $counter = 1; $counter <= $this->fields; $counter += 1 ) { 292 | $user_login = stripslashes( $_POST['user_login_' . $counter] ); 293 | $user_email = stripslashes( $_POST['user_email_' . $counter] ); 294 | $user_password = stripslashes( $_POST['user_password_' . $counter] ); 295 | $user_role = stripslashes( $_POST['user_role_' . $counter] ); 296 | $error = 0; 297 | $error_field = ''; 298 | $error_msg = ''; 299 | 300 | if ( !empty( $user_email ) || !empty( $user_login ) ) { 301 | 302 | // validate user email and login 303 | $validate_user = $this->validate_user_signup( $user_login, $user_email ); 304 | if( is_wp_error( $validate_user_errors = $validate_user[ 'errors' ] ) && !empty( $validate_user[ 'errors' ]->errors ) ) { 305 | foreach( $validate_user_errors->get_error_codes() as $error_code ) { 306 | $error_field = $error_code; 307 | $error_msg = $validate_user_errors->errors[$error_code][0]; 308 | $error = 1; 309 | } 310 | } 311 | 312 | // validate password 313 | if ( !empty( $user_password ) ) { 314 | if ( false !== strpos( stripslashes( $user_password ), ' ' ) ) { 315 | $error = 1; 316 | $error_field = 'user_password'; 317 | $error_msg = __( 'Passwords cannot contain spaces', 'add_new_users' ); 318 | } 319 | 320 | if ( false !== strpos( stripslashes( $user_password ), '\\' ) ) { 321 | $error = 1; 322 | $error_field = 'user_password'; 323 | $error_msg = __( 'Passwords may not contain the character "\\".', 'add_new_users' ); 324 | } 325 | } else { 326 | $user_password = 'empty'; 327 | } 328 | 329 | $add_new_users_items[$counter]['user_login'] = $validate_user['user_name']; 330 | $add_new_users_items[$counter]['user_email'] = $validate_user['user_email']; 331 | $add_new_users_items[$counter]['user_password'] = $user_password; 332 | $add_new_users_items[$counter]['user_role'] = $user_role; 333 | 334 | $errors[$counter] = $error; 335 | $error_fields[$counter] = $error_field; 336 | $error_messages[$counter] = $error_msg; 337 | if ( 1 == $error ) 338 | $global_errors = $global_errors + 1; 339 | 340 | } 341 | } 342 | 343 | // if there are errors, display them 344 | if ( $global_errors > 0 ) { 345 | 346 | echo '

' . __( 'Add New Users', 'add_new_users' ) . '

'; 347 | echo '

' . __( 'Errors were found. Please fix the errors and hit Next.', 'add_new_users' ) . '

'; 348 | 349 | if ( !empty( $_GET['fields'] ) ) 350 | echo "
"; 351 | else 352 | echo ''; 353 | 354 | wp_nonce_field( 'add-new-users-process_new_users' ); 355 | 356 | $this->formfields( $errors, $error_messages ); 357 | ?> 358 |

359 | 360 | 361 |

362 |

363 |
364 | 0 && is_array($add_new_users_items) ) { 373 | echo '

' . __( 'Adding Users...', 'add_new_users' ) . '

'; 374 | foreach( $add_new_users_items as $add_new_users_item ) { 375 | $this->queue_insert( $batch_ID, $add_new_users_item['user_login'], $add_new_users_item['user_email'], $add_new_users_item['user_password'], $add_new_users_item['user_role'] ); 376 | } 377 | } 378 | $queue_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}add_new_users_queue WHERE add_new_users_site_ID = '%d' AND add_new_users_blog_ID = '%d'", $wpdb->siteid, $wpdb->blogid ) ); 379 | 380 | if ( $queue_count > 0 ) 381 | echo ''; 382 | else 383 | echo ''; 384 | 385 | } 386 | break; 387 | 388 | default: 389 | echo '

' . __( 'Add New Users', 'add_new_users' ) . '

'; 390 | echo '

' . __( 'This tool allows you to create new users on this site and add them to this blog.', 'add_new_users' ) . '

'; 391 | echo class_exists( 'Add_Users' ) ? '

' . __( 'To add users that have already been created, please use the Add Users functionality here.', 'add_new_users' ) . '

' : ''; 392 | 393 | echo '

' . __( 'To add the new users simply enter the username you\'d like to give them (please choose carefully as it cannot be changed), their email address and - should you so choose - a password for them.', 'add_new_users' ) . '

'; 394 | echo '

' . __( 'You may also select the level that you wish them to access to the site - you can find out more about different levels of access here.', 'add_new_users' ) . '

'; 395 | echo '

' . __( 'If you do not enter a password a random one will be generated for them.', 'add_new_users' ) . '

'; 396 | echo '

' . __( 'All new users will receive an email containing their new username, password and login link.', 'add_new_users' ) . '

'; 397 | 398 | $fields = !empty( $_GET['fields'] ) ? "&fields=$_GET[fields]" : ''; 399 | 400 | echo "
"; 401 | wp_nonce_field( 'add-new-users-process_new_users' ); 402 | 403 | $this->formfields(); 404 | ?> 405 |

406 | is_supporter() && $this->supporter_only == 'yes' ) { echo 'disabled="disabled"'; } ?> type="submit" name="Submit" value="" /> 407 |

408 |

409 |
410 | '; 414 | } 415 | 416 | function formfields( $errors = '', $error_messages = '' ) { 417 | global $wp_roles; 418 | 419 | for ( $counter = 1; $counter <= $this->fields; $counter += 1) { 420 | if( isset( $errors[$counter] ) && 1 == $errors[$counter] ) { 421 | ?> 422 |

423 | 426 |

427 | 430 | 431 | 432 | 433 | 436 | 437 | 438 | 439 | 440 | 443 | 444 | 445 | 446 | 447 | 450 | 451 | 452 | 453 | 454 | 470 | 471 |
is_supporter() && $this->supporter_only == 'yes' ) { echo 'disabled="disabled"'; } ?> type="text" name="user_login_" id="user_login_" style="width: 95%" maxlength="200" value="" /> 434 |
435 |
is_supporter() && $this->supporter_only == 'yes' ) { echo 'disabled="disabled"'; } ?> type="text" name="user_email_" id="user_email_" style="width: 95%" maxlength="200" value="" /> 441 |
442 |
is_supporter() && $this->supporter_only == 'yes' ) { echo 'disabled="disabled"'; } ?> type="text" name="user_password_" id="user_password_" style="width: 95%" maxlength="200" value="" /> 448 |
449 |
468 |
469 |
472 |

' . __('Please install the latest version of our free Update Notifications plugin which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. More information »', 'wpmudev') . '

'; 491 | } 492 | } 493 | --------------------------------------------------------------------------------