| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * New User Administration Screen. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 /** 13 * @global wpdb $wpdb WordPress database abstraction object. 14 * @global int $blog_id The current site (blog) ID on multisite. 15 */ 16 global $wpdb, $blog_id; 17 18 if ( is_multisite() ) { 19 if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) { 20 wp_die( 21 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 22 '<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>', 23 403 24 ); 25 } 26 } elseif ( ! current_user_can( 'create_users' ) ) { 27 wp_die( 28 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 29 '<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>', 30 403 31 ); 32 } 33 34 if ( is_multisite() ) { 35 add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' ); 36 } 37 38 if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) { 39 check_admin_referer( 'add-user', '_wpnonce_add-user' ); 40 41 $user_details = null; 42 $user_email = wp_unslash( $_REQUEST['email'] ); 43 44 if ( str_contains( $user_email, '@' ) ) { 45 $user_details = get_user_by( 'email', $user_email ); 46 } else { 47 if ( current_user_can( 'manage_network_users' ) ) { 48 $user_details = get_user_by( 'login', $user_email ); 49 } else { 50 wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) ); 51 die(); 52 } 53 } 54 55 if ( ! $user_details ) { 56 wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) ); 57 die(); 58 } 59 60 if ( ! current_user_can( 'promote_user', $user_details->ID ) ) { 61 wp_die( 62 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 63 '<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>', 64 403 65 ); 66 } 67 68 // Adding an existing user to this blog. 69 $new_user_email = array(); 70 $redirect = 'user-new.php'; 71 $username = $user_details->user_login; 72 $user_id = $user_details->ID; 73 74 if ( array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) { 75 $redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' ); 76 } else { 77 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { 78 79 wp_ensure_editable_role( $_REQUEST['role'] ); 80 81 $result = add_existing_user_to_blog( 82 array( 83 'user_id' => $user_id, 84 'role' => $_REQUEST['role'], 85 ) 86 ); 87 88 if ( ! is_wp_error( $result ) ) { 89 $redirect = add_query_arg( 90 array( 91 'update' => 'addnoconfirmation', 92 'user_id' => $user_id, 93 ), 94 'user-new.php' 95 ); 96 } else { 97 $redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' ); 98 } 99 } else { 100 $newuser_key = wp_generate_password( 20, false ); 101 add_option( 102 'new_user_' . $newuser_key, 103 array( 104 'user_id' => $user_id, 105 'email' => $user_details->user_email, 106 'role' => $_REQUEST['role'], 107 ) 108 ); 109 110 $roles = get_editable_roles(); 111 $role = $roles[ $_REQUEST['role'] ]; 112 113 /** 114 * Fires immediately after an existing user is invited to join the site, but before the notification is sent. 115 * 116 * @since 4.4.0 117 * 118 * @param int $user_id The invited user's ID. 119 * @param array $role Array containing role information for the invited user. 120 * @param string $newuser_key The key of the invitation. 121 */ 122 do_action( 'invite_user', $user_id, $role, $newuser_key ); 123 124 $switched_locale = switch_to_user_locale( $user_id ); 125 126 if ( '' !== get_option( 'blogname' ) ) { 127 $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 128 } else { 129 $site_title = parse_url( home_url(), PHP_URL_HOST ); 130 } 131 132 /* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */ 133 $message = __( 134 'Hi, 135 136 You\'ve been invited to join \'%1$s\' at 137 %2$s with the role of %3$s. 138 139 Please click the following link to confirm the invite: 140 %4$s' 141 ); 142 143 $new_user_email['to'] = $user_details->user_email; 144 $new_user_email['subject'] = sprintf( 145 /* translators: Joining confirmation notification email subject. %s: Site title. */ 146 __( '[%s] Joining Confirmation' ), 147 $site_title 148 ); 149 $new_user_email['message'] = sprintf( 150 $message, 151 get_option( 'blogname' ), 152 home_url(), 153 wp_specialchars_decode( translate_user_role( $role['name'] ) ), 154 home_url( "/newbloguser/$newuser_key/" ) 155 ); 156 $new_user_email['headers'] = ''; 157 158 /** 159 * Filters the contents of the email sent when an existing user is invited to join the site. 160 * 161 * @since 5.6.0 162 * 163 * @param array $new_user_email { 164 * Used to build wp_mail(). 165 * 166 * @type string $to The email address of the invited user. 167 * @type string $subject The subject of the email. 168 * @type string $message The content of the email. 169 * @type string $headers Headers. 170 * } 171 * @param int $user_id The invited user's ID. 172 * @param array $role Array containing role information for the invited user. 173 * @param string $newuser_key The key of the invitation. 174 * 175 */ 176 $new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key ); 177 178 wp_mail( 179 $new_user_email['to'], 180 $new_user_email['subject'], 181 $new_user_email['message'], 182 $new_user_email['headers'] 183 ); 184 185 if ( $switched_locale ) { 186 restore_previous_locale(); 187 } 188 189 $redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' ); 190 } 191 } 192 193 wp_redirect( $redirect ); 194 die(); 195 } elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) { 196 check_admin_referer( 'create-user', '_wpnonce_create-user' ); 197 198 if ( ! current_user_can( 'create_users' ) ) { 199 wp_die( 200 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 201 '<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>', 202 403 203 ); 204 } 205 206 if ( ! is_multisite() ) { 207 $user_id = edit_user(); 208 209 if ( is_wp_error( $user_id ) ) { 210 $add_user_errors = $user_id; 211 } else { 212 if ( current_user_can( 'list_users' ) ) { 213 $redirect = 'users.php?update=add&id=' . $user_id; 214 } else { 215 $redirect = add_query_arg( 'update', 'add', 'user-new.php' ); 216 } 217 218 wp_redirect( $redirect ); 219 die(); 220 } 221 } else { 222 // Adding a new user to this site. 223 $new_user_email = wp_unslash( $_REQUEST['email'] ); 224 $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); 225 226 if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) { 227 $add_user_errors = $user_details['errors']; 228 } else { 229 /** This filter is documented in wp-includes/user.php */ 230 $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) ); 231 232 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { 233 add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email. 234 add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email. 235 } 236 237 wp_ensure_editable_role( $_REQUEST['role'] ); 238 239 wpmu_signup_user( 240 $new_user_login, 241 $new_user_email, 242 array( 243 'add_to_blog' => get_current_blog_id(), 244 'new_role' => $_REQUEST['role'], 245 ) 246 ); 247 248 if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { 249 $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 ) ); 250 $new_user = wpmu_activate_signup( $key ); 251 if ( is_wp_error( $new_user ) ) { 252 $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' ); 253 } elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) { 254 $redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' ); 255 } else { 256 $redirect = add_query_arg( 257 array( 258 'update' => 'addnoconfirmation', 259 'user_id' => $new_user['user_id'], 260 ), 261 'user-new.php' 262 ); 263 } 264 } else { 265 $redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' ); 266 } 267 268 wp_redirect( $redirect ); 269 die(); 270 } 271 } 272 } 273 274 // Used in the HTML title tag. 275 $title = __( 'Add User' ); 276 $parent_file = 'users.php'; 277 278 $do_both = false; 279 if ( is_multisite() && current_user_can( 'promote_users' ) && current_user_can( 'create_users' ) ) { 280 $do_both = true; 281 } 282 283 $help = '<p>' . __( 'To add a new user to your site, fill in the form on this screen and click the Add User button at the bottom.' ) . '</p>'; 284 285 if ( is_multisite() ) { 286 $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>' . 287 '<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 do not want the user to receive a welcome email.' ) . '</p>'; 288 } else { 289 $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>' . 290 291 '<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 do not want to send the new user a welcome email.' ) . '</p>'; 292 } 293 294 $help .= '<p>' . __( 'Remember to click the Add User button at the bottom of this screen when you are finished.' ) . '</p>'; 295 296 get_current_screen()->add_help_tab( 297 array( 298 'id' => 'overview', 299 'title' => __( 'Overview' ), 300 'content' => $help, 301 ) 302 ); 303 304 get_current_screen()->add_help_tab( 305 array( 306 'id' => 'user-roles', 307 'title' => __( 'User Roles' ), 308 'content' => '<p>' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '</p>' . 309 '<ul>' . 310 '<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' . 311 '<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' . 312 '<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' . 313 '<li>' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.' ) . '</li>' . 314 '<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' . 315 '</ul>', 316 ) 317 ); 318 319 get_current_screen()->set_help_sidebar( 320 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 321 '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' . 322 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 323 ); 324 325 wp_enqueue_script( 'wp-ajax-response' ); 326 wp_enqueue_script( 'user-profile' ); 327 328 /** 329 * Filters whether to enable user auto-complete for non-super admins in Multisite. 330 * 331 * @since 3.4.0 332 * 333 * @param bool $enable Whether to enable auto-complete for non-super admins. Default false. 334 */ 335 if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' ) 336 && ( current_user_can( 'manage_network_users' ) || apply_filters( 'autocomplete_users_for_site_admins', false ) ) 337 ) { 338 wp_enqueue_script( 'user-suggest' ); 339 } 340 341 require_once ABSPATH . 'wp-admin/admin-header.php'; 342 343 if ( isset( $_GET['update'] ) ) { 344 $messages = array(); 345 if ( is_multisite() ) { 346 $edit_link = ''; 347 if ( ( isset( $_GET['user_id'] ) ) ) { 348 $user_id_new = absint( $_GET['user_id'] ); 349 if ( $user_id_new ) { 350 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) ); 351 } 352 } 353 354 switch ( $_GET['update'] ) { 355 case 'newuserconfirmation': 356 $messages[] = __( 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.' ); 357 break; 358 case 'add': 359 $messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' ); 360 break; 361 case 'addnoconfirmation': 362 $message = __( 'User has been added to your site.' ); 363 364 if ( $edit_link ) { 365 $message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) ); 366 } 367 368 $messages[] = $message; 369 break; 370 case 'addexisting': 371 $messages[] = __( 'That user is already a member of this site.' ); 372 break; 373 case 'could_not_add': 374 $add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) ); 375 break; 376 case 'created_could_not_add': 377 $add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) ); 378 break; 379 case 'does_not_exist': 380 $add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) ); 381 break; 382 case 'enter_email': 383 $add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) ); 384 break; 385 } 386 } else { 387 if ( 'add' === $_GET['update'] ) { 388 $messages[] = __( 'User added.' ); 389 } 390 } 391 } 392 ?> 393 <div class="wrap"> 394 <h1 id="add-new-user"> 395 <?php 396 if ( current_user_can( 'create_users' ) ) { 397 _e( 'Add User' ); 398 } elseif ( current_user_can( 'promote_users' ) ) { 399 _e( 'Add Existing User' ); 400 } 401 ?> 402 </h1> 403 404 <?php 405 if ( isset( $errors ) && is_wp_error( $errors ) ) : 406 $error_message = ''; 407 foreach ( $errors->get_error_messages() as $err ) { 408 $error_message .= "<li>$err</li>\n"; 409 } 410 wp_admin_notice( 411 '<ul>' . $error_message . '</ul>', 412 array( 413 'additional_classes' => array( 'error' ), 414 'paragraph_wrap' => false, 415 ) 416 ); 417 endif; 418 419 if ( ! empty( $messages ) ) { 420 foreach ( $messages as $msg ) { 421 wp_admin_notice( 422 $msg, 423 array( 424 'id' => 'message', 425 'additional_classes' => array( 'updated' ), 426 'dismissible' => true, 427 ) 428 ); 429 } 430 } 431 ?> 432 433 <?php 434 if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : 435 $error_message = ''; 436 foreach ( $add_user_errors->get_error_messages() as $message ) { 437 $error_message .= "<p>$message</p>\n"; 438 } 439 wp_admin_notice( 440 $error_message, 441 array( 442 'additional_classes' => array( 'error' ), 443 'paragraph_wrap' => false, 444 ) 445 ); 446 endif; 447 ?> 448 <div id="ajax-response"></div> 449 450 <?php 451 if ( is_multisite() && current_user_can( 'promote_users' ) ) { 452 if ( $do_both ) { 453 echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>'; 454 } 455 if ( ! current_user_can( 'manage_network_users' ) ) { 456 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>'; 457 $label = __( 'Email' ); 458 $type = 'email'; 459 } else { 460 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>'; 461 $label = __( 'Email or Username' ); 462 $type = 'text'; 463 } 464 ?> 465 <form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate" 466 <?php 467 /** 468 * Fires inside the adduser form tag. 469 * 470 * @since 3.0.0 471 */ 472 do_action( 'user_new_form_tag' ); 473 ?> 474 > 475 <input name="action" type="hidden" value="adduser" /> 476 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?> 477 478 <table class="form-table" role="presentation"> 479 <tr class="form-field form-required"> 480 <th scope="row"><label for="adduser-email"><?php echo esc_html( $label ); ?></label></th> 481 <td><input name="email" type="<?php echo esc_attr( $type ); ?>" id="adduser-email" class="wp-suggest-user" value="" /></td> 482 </tr> 483 <tr class="form-field"> 484 <th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th> 485 <td><select name="role" id="adduser-role"> 486 <?php wp_dropdown_roles( get_option( 'default_role' ) ); ?> 487 </select> 488 </td> 489 </tr> 490 <?php if ( current_user_can( 'manage_network_users' ) ) { ?> 491 <tr> 492 <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th> 493 <td> 494 <input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> 495 <label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label> 496 </td> 497 </tr> 498 <?php } ?> 499 </table> 500 <?php 501 /** 502 * Fires at the end of the new user form. 503 * 504 * Passes a contextual string to make both types of new user forms 505 * uniquely targetable. Contexts are 'add-existing-user' (Multisite), 506 * and 'add-new-user' (single site and network admin). 507 * 508 * @since 3.7.0 509 * 510 * @param string $type A contextual string specifying which type of new user form the hook follows. 511 */ 512 do_action( 'user_new_form', 'add-existing-user' ); 513 ?> 514 <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> 515 </form> 516 <?php 517 } // End if is_multisite(). 518 519 if ( current_user_can( 'create_users' ) ) { 520 if ( $do_both ) { 521 echo '<h2 id="create-new-user">' . __( 'Add User' ) . '</h2>'; 522 } 523 ?> 524 <p><?php _e( 'Create a brand new user and add them to this site.' ); ?></p> 525 <form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate" 526 <?php 527 /** This action is documented in wp-admin/user-new.php */ 528 do_action( 'user_new_form_tag' ); 529 ?> 530 > 531 <input name="action" type="hidden" value="createuser" /> 532 <?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?> 533 <?php 534 // Load up the passed data, else set to a default. 535 $creating = isset( $_POST['createuser'] ); 536 537 $new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : ''; 538 $new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : ''; 539 $new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : ''; 540 $new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : ''; 541 $new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : ''; 542 $new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : ''; 543 $new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true; 544 $new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : ''; 545 546 ?> 547 <table class="form-table" role="presentation"> 548 <tr class="form-field form-required"> 549 <th scope="row"><label for="user_login"><?php _e( 'Username' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 550 <td><input name="user_login" type="text" id="user_login" class="ltr" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" autocomplete="off" maxlength="60" /></td> 551 </tr> 552 <tr class="form-field form-required"> 553 <th scope="row"><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 554 <td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td> 555 </tr> 556 <?php if ( ! is_multisite() ) { ?> 557 <tr class="form-field"> 558 <th scope="row"><label for="first_name"><?php _e( 'First Name' ); ?> </label></th> 559 <td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr( $new_user_firstname ); ?>" /></td> 560 </tr> 561 <tr class="form-field"> 562 <th scope="row"><label for="last_name"><?php _e( 'Last Name' ); ?> </label></th> 563 <td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr( $new_user_lastname ); ?>" /></td> 564 </tr> 565 <tr class="form-field"> 566 <th scope="row"><label for="url"><?php _e( 'Website' ); ?></label></th> 567 <td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td> 568 </tr> 569 <?php 570 $languages = get_available_languages(); 571 if ( $languages ) : 572 ?> 573 <tr class="form-field user-language-wrap"> 574 <th scope="row"> 575 <label for="locale"> 576 <?php /* translators: The user language selection field label. */ ?> 577 <?php _e( 'Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span> 578 </label> 579 </th> 580 <td> 581 <?php 582 wp_dropdown_languages( 583 array( 584 'name' => 'locale', 585 'id' => 'locale', 586 'selected' => 'site-default', 587 'languages' => $languages, 588 'show_available_translations' => false, 589 'show_option_site_default' => true, 590 ) 591 ); 592 ?> 593 </td> 594 </tr> 595 <?php endif; ?> 596 <tr class="form-field form-required user-pass1-wrap"> 597 <th scope="row"> 598 <label for="pass1"> 599 <?php _e( 'Password' ); ?> 600 <span class="description hide-if-js"><?php _e( '(required)' ); ?></span> 601 </label> 602 </th> 603 <td> 604 <input type="hidden" value=" " /><!-- #24364 workaround --> 605 <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate password' ); ?></button> 606 <div class="wp-pwd"> 607 <?php $initial_password = wp_generate_password( 24 ); ?> 608 <div class="password-input-wrapper"> 609 <input type="password" name="pass1" id="pass1" class="regular-text ltr" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> 610 <div style="display:none" id="pass-strength-result" aria-live="polite"></div> 611 </div> 612 <button type="button" class="button wp-hide-pw user-new-password-toggle hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 613 <span class="dashicons dashicons-hidden" aria-hidden="true"></span> 614 <span class="text"><?php _e( 'Hide' ); ?></span> 615 </button> 616 </div> 617 </td> 618 </tr> 619 <tr class="form-field form-required user-pass2-wrap hide-if-js"> 620 <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 621 <td> 622 <input type="password" name="pass2" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" /> 623 <p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p> 624 </td> 625 </tr> 626 <tr class="pw-weak"> 627 <th><?php _e( 'Confirm Password' ); ?></th> 628 <td> 629 <label> 630 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 631 <?php _e( 'Confirm use of weak password' ); ?> 632 </label> 633 </td> 634 </tr> 635 <tr> 636 <th scope="row"><?php _e( 'Send User Notification' ); ?></th> 637 <td> 638 <input type="checkbox" name="send_user_notification" id="send_user_notification" value="1" <?php checked( $new_user_send_notification ); ?> /> 639 <label for="send_user_notification"><?php _e( 'Send the new user an email about their account' ); ?></label> 640 </td> 641 </tr> 642 <?php } // End if ! is_multisite(). ?> 643 <?php if ( current_user_can( 'promote_users' ) ) { ?> 644 <tr class="form-field"> 645 <th scope="row"><label for="role"><?php _e( 'Role' ); ?></label></th> 646 <td><select name="role" id="role"> 647 <?php 648 if ( ! $new_user_role ) { 649 $new_user_role = get_option( 'default_role' ); 650 } 651 wp_dropdown_roles( $new_user_role ); 652 ?> 653 </select> 654 </td> 655 </tr> 656 <?php } ?> 657 <?php if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { ?> 658 <tr> 659 <th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th> 660 <td> 661 <input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> /> 662 <label for="noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation' ); ?></label> 663 </td> 664 </tr> 665 <?php } ?> 666 </table> 667 668 <?php 669 /** This action is documented in wp-admin/user-new.php */ 670 do_action( 'user_new_form', 'add-new-user' ); 671 ?> 672 673 <?php submit_button( __( 'Add User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?> 674 675 </form> 676 <?php } // End if current_user_can( 'create_users' ). ?> 677 </div> 678 <?php 679 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Nov 13 08:20:01 2026 | Cross-referenced by PHPXref |