58 ); |
58 ); |
59 } |
59 } |
60 |
60 |
61 // Adding an existing user to this blog |
61 // Adding an existing user to this blog |
62 $new_user_email = $user_details->user_email; |
62 $new_user_email = $user_details->user_email; |
63 $redirect = 'user-new.php'; |
63 $redirect = 'user-new.php'; |
64 $username = $user_details->user_login; |
64 $username = $user_details->user_login; |
65 $user_id = $user_details->ID; |
65 $user_id = $user_details->ID; |
66 if ( $username != null && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) { |
66 if ( $username != null && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) { |
67 $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); |
67 $redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' ); |
68 } else { |
68 } else { |
69 if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) { |
69 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { |
70 $result = add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); |
70 $result = add_existing_user_to_blog( |
|
71 array( |
|
72 'user_id' => $user_id, |
|
73 'role' => $_REQUEST['role'], |
|
74 ) |
|
75 ); |
71 |
76 |
72 if ( ! is_wp_error( $result ) ) { |
77 if ( ! is_wp_error( $result ) ) { |
73 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation', 'user_id' => $user_id ), 'user-new.php' ); |
78 $redirect = add_query_arg( |
|
79 array( |
|
80 'update' => 'addnoconfirmation', |
|
81 'user_id' => $user_id, |
|
82 ), |
|
83 'user-new.php' |
|
84 ); |
74 } else { |
85 } else { |
75 $redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' ); |
86 $redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' ); |
76 } |
87 } |
77 } else { |
88 } else { |
78 $newuser_key = wp_generate_password( 20, false ); |
89 $newuser_key = wp_generate_password( 20, false ); |
79 add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); |
90 add_option( |
|
91 'new_user_' . $newuser_key, |
|
92 array( |
|
93 'user_id' => $user_id, |
|
94 'email' => $user_details->user_email, |
|
95 'role' => $_REQUEST['role'], |
|
96 ) |
|
97 ); |
80 |
98 |
81 $roles = get_editable_roles(); |
99 $roles = get_editable_roles(); |
82 $role = $roles[ $_REQUEST['role'] ]; |
100 $role = $roles[ $_REQUEST['role'] ]; |
83 |
101 |
84 /** |
102 /** |
85 * Fires immediately after a user is invited to join a site, but before the notification is sent. |
103 * Fires immediately after a user is invited to join a site, but before the notification is sent. |
86 * |
104 * |
87 * @since 4.4.0 |
105 * @since 4.4.0 |
128 $user_id = edit_user(); |
150 $user_id = edit_user(); |
129 |
151 |
130 if ( is_wp_error( $user_id ) ) { |
152 if ( is_wp_error( $user_id ) ) { |
131 $add_user_errors = $user_id; |
153 $add_user_errors = $user_id; |
132 } else { |
154 } else { |
133 if ( current_user_can( 'list_users' ) ) |
155 if ( current_user_can( 'list_users' ) ) { |
134 $redirect = 'users.php?update=add&id=' . $user_id; |
156 $redirect = 'users.php?update=add&id=' . $user_id; |
135 else |
157 } else { |
136 $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); |
158 $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); |
|
159 } |
137 wp_redirect( $redirect ); |
160 wp_redirect( $redirect ); |
138 die(); |
161 die(); |
139 } |
162 } |
140 } else { |
163 } else { |
141 // Adding a new user to this site |
164 // Adding a new user to this site |
142 $new_user_email = wp_unslash( $_REQUEST['email'] ); |
165 $new_user_email = wp_unslash( $_REQUEST['email'] ); |
143 $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); |
166 $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); |
144 if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) { |
167 if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) { |
145 $add_user_errors = $user_details[ 'errors' ]; |
168 $add_user_errors = $user_details['errors']; |
146 } else { |
169 } else { |
147 /** |
170 /** This filter is documented in wp-includes/user.php */ |
148 * Filters the user_login, also known as the username, before it is added to the site. |
|
149 * |
|
150 * @since 2.0.3 |
|
151 * |
|
152 * @param string $user_login The sanitized username. |
|
153 */ |
|
154 $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) ); |
171 $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) ); |
155 if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) { |
172 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { |
156 add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email |
173 add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email |
157 add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email |
174 add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email |
158 } |
175 } |
159 wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => get_current_blog_id(), 'new_role' => $_REQUEST['role'] ) ); |
176 wpmu_signup_user( |
160 if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) { |
177 $new_user_login, |
161 $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) ); |
178 $new_user_email, |
|
179 array( |
|
180 'add_to_blog' => get_current_blog_id(), |
|
181 'new_role' => $_REQUEST['role'], |
|
182 ) |
|
183 ); |
|
184 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { |
|
185 $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) ); |
162 $new_user = wpmu_activate_signup( $key ); |
186 $new_user = wpmu_activate_signup( $key ); |
163 if ( is_wp_error( $new_user ) ) { |
187 if ( is_wp_error( $new_user ) ) { |
164 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' ); |
188 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' ); |
165 } elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) { |
189 } elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) { |
166 $redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' ); |
190 $redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' ); |
167 } else { |
191 } else { |
168 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation', 'user_id' => $new_user['user_id'] ), 'user-new.php' ); |
192 $redirect = add_query_arg( |
|
193 array( |
|
194 'update' => 'addnoconfirmation', |
|
195 'user_id' => $new_user['user_id'], |
|
196 ), |
|
197 'user-new.php' |
|
198 ); |
169 } |
199 } |
170 } else { |
200 } else { |
171 $redirect = add_query_arg( array('update' => 'newuserconfirmation'), 'user-new.php' ); |
201 $redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' ); |
172 } |
202 } |
173 wp_redirect( $redirect ); |
203 wp_redirect( $redirect ); |
174 die(); |
204 die(); |
175 } |
205 } |
176 } |
206 } |
177 } |
207 } |
178 |
208 |
179 $title = __('Add New User'); |
209 $title = __( 'Add New User' ); |
180 $parent_file = 'users.php'; |
210 $parent_file = 'users.php'; |
181 |
211 |
182 $do_both = false; |
212 $do_both = false; |
183 if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') ) |
213 if ( is_multisite() && current_user_can( 'promote_users' ) && current_user_can( 'create_users' ) ) { |
184 $do_both = true; |
214 $do_both = true; |
185 |
215 } |
186 $help = '<p>' . __('To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.') . '</p>'; |
216 |
|
217 $help = '<p>' . __( 'To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.' ) . '</p>'; |
187 |
218 |
188 if ( is_multisite() ) { |
219 if ( is_multisite() ) { |
189 $help .= '<p>' . __('Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.') . '</p>' . |
220 $help .= '<p>' . __( 'Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.' ) . '</p>' . |
190 '<p>' . __('New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their password. Check the box if you don’t want the user to receive a welcome email.') . '</p>'; |
221 '<p>' . __( 'New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their password. Check the box if you don’t want the user to receive a welcome email.' ) . '</p>'; |
191 } else { |
222 } else { |
192 $help .= '<p>' . __('New users are automatically assigned a password, which they can change after logging in. You can view or edit the assigned password by clicking the Show Password button. The username cannot be changed once the user has been added.') . '</p>' . |
223 $help .= '<p>' . __( 'New users are automatically assigned a password, which they can change after logging in. You can view or edit the assigned password by clicking the Show Password button. The username cannot be changed once the user has been added.' ) . '</p>' . |
193 |
224 |
194 '<p>' . __('By default, new users will receive an email letting them know they’ve been added as a user for your site. This email will also contain a password reset link. Uncheck the box if you don’t want to send the new user a welcome email.') . '</p>'; |
225 '<p>' . __( 'By default, new users will receive an email letting them know they’ve been added as a user for your site. This email will also contain a password reset link. Uncheck the box if you don’t want to send the new user a welcome email.' ) . '</p>'; |
195 } |
226 } |
196 |
227 |
197 $help .= '<p>' . __('Remember to click the Add New User button at the bottom of this screen when you are finished.') . '</p>'; |
228 $help .= '<p>' . __( 'Remember to click the Add New User button at the bottom of this screen when you are finished.' ) . '</p>'; |
198 |
229 |
199 get_current_screen()->add_help_tab( array( |
230 get_current_screen()->add_help_tab( |
200 'id' => 'overview', |
231 array( |
201 'title' => __('Overview'), |
232 'id' => 'overview', |
202 'content' => $help, |
233 'title' => __( 'Overview' ), |
203 ) ); |
234 'content' => $help, |
204 |
235 ) |
205 get_current_screen()->add_help_tab( array( |
236 ); |
206 'id' => 'user-roles', |
237 |
207 'title' => __('User Roles'), |
238 get_current_screen()->add_help_tab( |
208 'content' => '<p>' . __('Here is a basic overview of the different user roles and the permissions associated with each one:') . '</p>' . |
239 array( |
209 '<ul>' . |
240 'id' => 'user-roles', |
210 '<li>' . __('Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.') . '</li>' . |
241 'title' => __( 'User Roles' ), |
211 '<li>' . __('Contributors can write and manage their posts but not publish posts or upload media files.') . '</li>' . |
242 'content' => '<p>' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '</p>' . |
212 '<li>' . __('Authors can publish and manage their own posts, and are able to upload files.') . '</li>' . |
243 '<ul>' . |
213 '<li>' . __('Editors can publish posts, manage posts as well as manage other people’s posts, etc.') . '</li>' . |
244 '<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' . |
214 '<li>' . __('Administrators have access to all the administration features.') . '</li>' . |
245 '<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' . |
215 '</ul>' |
246 '<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' . |
216 ) ); |
247 '<li>' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.' ) . '</li>' . |
|
248 '<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' . |
|
249 '</ul>', |
|
250 ) |
|
251 ); |
217 |
252 |
218 get_current_screen()->set_help_sidebar( |
253 get_current_screen()->set_help_sidebar( |
219 '<p><strong>' . __('For more information:') . '</strong></p>' . |
254 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
220 '<p>' . __('<a href="https://codex.wordpress.org/Users_Add_New_Screen">Documentation on Adding New Users</a>') . '</p>' . |
255 '<p>' . __( '<a href="https://codex.wordpress.org/Users_Add_New_Screen">Documentation on Adding New Users</a>' ) . '</p>' . |
221 '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
256 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
222 ); |
257 ); |
223 |
258 |
224 wp_enqueue_script('wp-ajax-response'); |
259 wp_enqueue_script( 'wp-ajax-response' ); |
225 wp_enqueue_script( 'user-profile' ); |
260 wp_enqueue_script( 'user-profile' ); |
226 |
261 |
227 /** |
262 /** |
228 * Filters whether to enable user auto-complete for non-super admins in Multisite. |
263 * Filters whether to enable user auto-complete for non-super admins in Multisite. |
229 * |
264 * |
249 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) ); |
284 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) ); |
250 } |
285 } |
251 } |
286 } |
252 |
287 |
253 switch ( $_GET['update'] ) { |
288 switch ( $_GET['update'] ) { |
254 case "newuserconfirmation": |
289 case 'newuserconfirmation': |
255 $messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.'); |
290 $messages[] = __( 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.' ); |
256 break; |
291 break; |
257 case "add": |
292 case 'add': |
258 $messages[] = __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.'); |
293 $messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' ); |
259 break; |
294 break; |
260 case "addnoconfirmation": |
295 case 'addnoconfirmation': |
261 if ( empty( $edit_link ) ) { |
296 if ( empty( $edit_link ) ) { |
262 $messages[] = __( 'User has been added to your site.' ); |
297 $messages[] = __( 'User has been added to your site.' ); |
263 } else { |
298 } else { |
264 /* translators: %s: edit page url */ |
299 /* translators: %s: edit page url */ |
265 $messages[] = sprintf( __( 'User has been added to your site. <a href="%s">Edit user</a>' ), $edit_link ); |
300 $messages[] = sprintf( __( 'User has been added to your site. <a href="%s">Edit user</a>' ), $edit_link ); |
266 } |
301 } |
267 break; |
302 break; |
268 case "addexisting": |
303 case 'addexisting': |
269 $messages[] = __('That user is already a member of this site.'); |
304 $messages[] = __( 'That user is already a member of this site.' ); |
270 break; |
305 break; |
271 case "could_not_add": |
306 case 'could_not_add': |
272 $add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) ); |
307 $add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) ); |
273 break; |
308 break; |
274 case "created_could_not_add": |
309 case 'created_could_not_add': |
275 $add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) ); |
310 $add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) ); |
276 break; |
311 break; |
277 case "does_not_exist": |
312 case 'does_not_exist': |
278 $add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) ); |
313 $add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) ); |
279 break; |
314 break; |
280 case "enter_email": |
315 case 'enter_email': |
281 $add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) ); |
316 $add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) ); |
282 break; |
317 break; |
283 } |
318 } |
284 } else { |
319 } else { |
285 if ( 'add' == $_GET['update'] ) |
320 if ( 'add' == $_GET['update'] ) { |
286 $messages[] = __('User added.'); |
321 $messages[] = __( 'User added.' ); |
|
322 } |
287 } |
323 } |
288 } |
324 } |
289 ?> |
325 ?> |
290 <div class="wrap"> |
326 <div class="wrap"> |
291 <h1 id="add-new-user"><?php |
327 <h1 id="add-new-user"> |
|
328 <?php |
292 if ( current_user_can( 'create_users' ) ) { |
329 if ( current_user_can( 'create_users' ) ) { |
293 _e( 'Add New User' ); |
330 _e( 'Add New User' ); |
294 } elseif ( current_user_can( 'promote_users' ) ) { |
331 } elseif ( current_user_can( 'promote_users' ) ) { |
295 _e( 'Add Existing User' ); |
332 _e( 'Add Existing User' ); |
296 } ?> |
333 } |
|
334 ?> |
297 </h1> |
335 </h1> |
298 |
336 |
299 <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> |
337 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
300 <div class="error"> |
338 <div class="error"> |
301 <ul> |
339 <ul> |
302 <?php |
340 <?php |
303 foreach ( $errors->get_error_messages() as $err ) |
341 foreach ( $errors->get_error_messages() as $err ) { |
304 echo "<li>$err</li>\n"; |
342 echo "<li>$err</li>\n"; |
|
343 } |
305 ?> |
344 ?> |
306 </ul> |
345 </ul> |
307 </div> |
346 </div> |
308 <?php endif; |
347 <?php |
|
348 endif; |
309 |
349 |
310 if ( ! empty( $messages ) ) { |
350 if ( ! empty( $messages ) ) { |
311 foreach ( $messages as $msg ) |
351 foreach ( $messages as $msg ) { |
312 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
352 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
313 } ?> |
353 } |
314 |
354 } |
315 <?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?> |
355 ?> |
|
356 |
|
357 <?php if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : ?> |
316 <div class="error"> |
358 <div class="error"> |
317 <?php |
359 <?php |
318 foreach ( $add_user_errors->get_error_messages() as $message ) |
360 foreach ( $add_user_errors->get_error_messages() as $message ) { |
319 echo "<p>$message</p>"; |
361 echo "<p>$message</p>"; |
|
362 } |
320 ?> |
363 ?> |
321 </div> |
364 </div> |
322 <?php endif; ?> |
365 <?php endif; ?> |
323 <div id="ajax-response"></div> |
366 <div id="ajax-response"></div> |
324 |
367 |
325 <?php |
368 <?php |
326 if ( is_multisite() && current_user_can( 'promote_users' ) ) { |
369 if ( is_multisite() && current_user_can( 'promote_users' ) ) { |
327 if ( $do_both ) |
370 if ( $do_both ) { |
328 echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>'; |
371 echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>'; |
|
372 } |
329 if ( ! current_user_can( 'manage_network_users' ) ) { |
373 if ( ! current_user_can( 'manage_network_users' ) ) { |
330 echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
374 echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
331 $label = __('Email'); |
375 $label = __( 'Email' ); |
332 $type = 'email'; |
376 $type = 'email'; |
333 } else { |
377 } else { |
334 echo '<p>' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
378 echo '<p>' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>'; |
335 $label = __('Email or Username'); |
379 $label = __( 'Email or Username' ); |
336 $type = 'text'; |
380 $type = 'text'; |
337 } |
381 } |
338 ?> |
382 ?> |
339 <form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"<?php |
383 <form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate" |
|
384 <?php |
340 /** |
385 /** |
341 * Fires inside the adduser form tag. |
386 * Fires inside the adduser form tag. |
342 * |
387 * |
343 * @since 3.0.0 |
388 * @since 3.0.0 |
344 */ |
389 */ |
345 do_action( 'user_new_form_tag' ); |
390 do_action( 'user_new_form_tag' ); |
346 ?>> |
391 ?> |
|
392 > |
347 <input name="action" type="hidden" value="adduser" /> |
393 <input name="action" type="hidden" value="adduser" /> |
348 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?> |
394 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?> |
349 |
395 |
350 <table class="form-table"> |
396 <table class="form-table" role="presentation"> |
351 <tr class="form-field form-required"> |
397 <tr class="form-field form-required"> |
352 <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th> |
398 <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th> |
353 <td><input name="email" type="<?php echo $type; ?>" id="adduser-email" class="wp-suggest-user" value="" /></td> |
399 <td><input name="email" type="<?php echo $type; ?>" id="adduser-email" class="wp-suggest-user" value="" /></td> |
354 </tr> |
400 </tr> |
355 <tr class="form-field"> |
401 <tr class="form-field"> |
356 <th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th> |
402 <th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th> |
357 <td><select name="role" id="adduser-role"> |
403 <td><select name="role" id="adduser-role"> |
358 <?php wp_dropdown_roles( get_option('default_role') ); ?> |
404 <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?> |
359 </select> |
405 </select> |
360 </td> |
406 </td> |
361 </tr> |
407 </tr> |
362 <?php if ( current_user_can( 'manage_network_users' ) ) { ?> |
408 <?php if ( current_user_can( 'manage_network_users' ) ) { ?> |
363 <tr> |
409 <tr> |
364 <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th> |
410 <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th> |
365 <td> |
411 <td> |
366 <input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> |
412 <input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> |
367 <label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label> |
413 <label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label> |
368 </td> |
414 </td> |
369 </tr> |
415 </tr> |
370 <?php } ?> |
416 <?php } ?> |
371 </table> |
417 </table> |
372 <?php |
418 <?php |
373 /** |
419 /** |
374 * Fires at the end of the new user form. |
420 * Fires at the end of the new user form. |
375 * |
421 * |
376 * Passes a contextual string to make both types of new user forms |
422 * Passes a contextual string to make both types of new user forms |
377 * uniquely targetable. Contexts are 'add-existing-user' (Multisite), |
423 * uniquely targetable. Contexts are 'add-existing-user' (Multisite), |
378 * and 'add-new-user' (single site and network admin). |
424 * and 'add-new-user' (single site and network admin). |
379 * |
425 * |
380 * @since 3.7.0 |
426 * @since 3.7.0 |
381 * |
427 * |
382 * @param string $type A contextual string specifying which type of new user form the hook follows. |
428 * @param string $type A contextual string specifying which type of new user form the hook follows. |
383 */ |
429 */ |
384 do_action( 'user_new_form', 'add-existing-user' ); |
430 do_action( 'user_new_form', 'add-existing-user' ); |
385 ?> |
431 ?> |
386 <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> |
432 <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> |
387 </form> |
433 </form> |
388 <?php |
434 <?php |
389 } // is_multisite() |
435 } // is_multisite() |
390 |
436 |
391 if ( current_user_can( 'create_users') ) { |
437 if ( current_user_can( 'create_users' ) ) { |
392 if ( $do_both ) |
438 if ( $do_both ) { |
393 echo '<h2 id="create-new-user">' . __( 'Add New User' ) . '</h2>'; |
439 echo '<h2 id="create-new-user">' . __( 'Add New User' ) . '</h2>'; |
394 ?> |
440 } |
395 <p><?php _e('Create a brand new user and add them to this site.'); ?></p> |
441 ?> |
396 <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php |
442 <p><?php _e( 'Create a brand new user and add them to this site.' ); ?></p> |
|
443 <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate" |
|
444 <?php |
397 /** This action is documented in wp-admin/user-new.php */ |
445 /** This action is documented in wp-admin/user-new.php */ |
398 do_action( 'user_new_form_tag' ); |
446 do_action( 'user_new_form_tag' ); |
399 ?>> |
447 ?> |
|
448 > |
400 <input name="action" type="hidden" value="createuser" /> |
449 <input name="action" type="hidden" value="createuser" /> |
401 <?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?> |
450 <?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?> |
402 <?php |
451 <?php |
403 // Load up the passed data, else set to a default. |
452 // Load up the passed data, else set to a default. |
404 $creating = isset( $_POST['createuser'] ); |
453 $creating = isset( $_POST['createuser'] ); |
405 |
454 |
406 $new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : ''; |
455 $new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : ''; |
407 $new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : ''; |
456 $new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : ''; |
408 $new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : ''; |
457 $new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : ''; |
409 $new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; |
458 $new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; |
410 $new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : ''; |
459 $new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : ''; |
411 $new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : ''; |
460 $new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : ''; |
412 $new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true; |
461 $new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true; |
413 $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : ''; |
462 $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : ''; |
414 |
463 |
415 ?> |
464 ?> |
416 <table class="form-table"> |
465 <table class="form-table" role="presentation"> |
417 <tr class="form-field form-required"> |
466 <tr class="form-field form-required"> |
418 <th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
467 <th scope="row"><label for="user_login"><?php _e( 'Username' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> |
419 <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" /></td> |
468 <td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" /></td> |
420 </tr> |
469 </tr> |
421 <tr class="form-field form-required"> |
470 <tr class="form-field form-required"> |
422 <th scope="row"><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
471 <th scope="row"><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> |
423 <td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td> |
472 <td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td> |
424 </tr> |
473 </tr> |
425 <?php if ( !is_multisite() ) { ?> |
474 <?php if ( ! is_multisite() ) { ?> |
426 <tr class="form-field"> |
475 <tr class="form-field"> |
427 <th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th> |
476 <th scope="row"><label for="first_name"><?php _e( 'First Name' ); ?> </label></th> |
428 <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr($new_user_firstname); ?>" /></td> |
477 <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr( $new_user_firstname ); ?>" /></td> |
429 </tr> |
478 </tr> |
430 <tr class="form-field"> |
479 <tr class="form-field"> |
431 <th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th> |
480 <th scope="row"><label for="last_name"><?php _e( 'Last Name' ); ?> </label></th> |
432 <td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr($new_user_lastname); ?>" /></td> |
481 <td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr( $new_user_lastname ); ?>" /></td> |
433 </tr> |
482 </tr> |
434 <tr class="form-field"> |
483 <tr class="form-field"> |
435 <th scope="row"><label for="url"><?php _e('Website') ?></label></th> |
484 <th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th> |
436 <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td> |
485 <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td> |
437 </tr> |
486 </tr> |
438 <tr class="form-field form-required user-pass1-wrap"> |
487 <tr class="form-field form-required user-pass1-wrap"> |
439 <th scope="row"> |
488 <th scope="row"> |
440 <label for="pass1"> |
489 <label for="pass1"> |