| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * User administration panel 4 * 5 * @package WordPress 6 * @subpackage Administration 7 * @since 1.0.0 8 */ 9 10 /** WordPress Administration Bootstrap */ 11 require_once __DIR__ . '/admin.php'; 12 13 if ( ! current_user_can( 'list_users' ) ) { 14 wp_die( 15 '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . 16 '<p>' . __( 'Sorry, you are not allowed to list users.' ) . '</p>', 17 403 18 ); 19 } 20 21 $wp_list_table = _get_list_table( 'WP_Users_List_Table' ); 22 $pagenum = $wp_list_table->get_pagenum(); 23 24 // Used in the HTML title tag. 25 $title = __( 'Users' ); 26 $parent_file = 'users.php'; 27 28 add_screen_option( 'per_page' ); 29 30 // Contextual help - choose Help on the top right of admin panel to preview this. 31 get_current_screen()->add_help_tab( 32 array( 33 'id' => 'overview', 34 'title' => __( 'Overview' ), 35 'content' => '<p>' . __( 'This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.' ) . '</p>' . 36 '<p>' . __( 'To add a new user for your site, click the Add User button at the top of the screen or Add User in the Users menu section.' ) . '</p>', 37 ) 38 ); 39 40 get_current_screen()->add_help_tab( 41 array( 42 'id' => 'screen-content', 43 'title' => __( 'Screen Content' ), 44 'content' => '<p>' . __( 'You can customize the display of this screen in a number of ways:' ) . '</p>' . 45 '<ul>' . 46 '<li>' . __( 'You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.' ) . '</li>' . 47 '<li>' . __( 'You can filter the list of users by User Role using the text links above the users list to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.' ) . '</li>' . 48 '<li>' . __( 'You can view all posts made by a user by clicking on the number under the Posts column.' ) . '</li>' . 49 '</ul>', 50 ) 51 ); 52 53 $help = '<p>' . __( 'Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:' ) . '</p>' . 54 '<ul>' . 55 '<li>' . __( '<strong>Edit</strong> takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.' ) . '</li>'; 56 57 if ( is_multisite() ) { 58 $help .= '<li>' . __( '<strong>Remove</strong> allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using bulk actions.' ) . '</li>'; 59 } else { 60 $help .= '<li>' . __( '<strong>Delete</strong> brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using bulk actions.' ) . '</li>'; 61 } 62 63 $help .= '<li>' . __( '<strong>View</strong> takes you to a public author archive which lists all the posts published by the user.' ) . '</li>'; 64 65 if ( current_user_can( 'edit_users' ) ) { 66 $help .= '<li>' . __( '<strong>Send password reset</strong> sends the user an email with a link to set a new password.' ) . '</li>'; 67 } 68 69 $help .= '</ul>'; 70 71 get_current_screen()->add_help_tab( 72 array( 73 'id' => 'action-links', 74 'title' => __( 'Available Actions' ), 75 'content' => $help, 76 ) 77 ); 78 unset( $help ); 79 80 get_current_screen()->set_help_sidebar( 81 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 82 '<p>' . __( '<a href="https://wordpress.org/documentation/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' . 83 '<p>' . __( '<a href="https://wordpress.org/documentation/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' . 84 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 85 ); 86 87 get_current_screen()->set_screen_reader_content( 88 array( 89 'heading_views' => __( 'Filter users list' ), 90 'heading_pagination' => __( 'Users list navigation' ), 91 'heading_list' => __( 'Users list' ), 92 ) 93 ); 94 95 if ( empty( $_REQUEST ) ) { 96 $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; 97 } elseif ( isset( $_REQUEST['wp_http_referer'] ) ) { 98 $redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) ); 99 $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />'; 100 } else { 101 $redirect = 'users.php'; 102 $referer = ''; 103 } 104 105 $update = ''; 106 107 switch ( $wp_list_table->current_action() ) { 108 109 /* Bulk Dropdown menu Role changes */ 110 case 'promote': 111 check_admin_referer( 'bulk-users' ); 112 113 if ( ! current_user_can( 'promote_users' ) ) { 114 wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); 115 } 116 117 if ( empty( $_REQUEST['users'] ) ) { 118 wp_redirect( $redirect ); 119 exit; 120 } 121 122 $editable_roles = get_editable_roles(); 123 $role = $_REQUEST['new_role']; 124 125 // Mock `none` as editable role. 126 $editable_roles['none'] = array( 127 'name' => __( '— No role for this site —' ), 128 ); 129 130 if ( ! $role || empty( $editable_roles[ $role ] ) ) { 131 wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); 132 } 133 134 if ( 'none' === $role ) { 135 $role = ''; 136 } 137 138 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 139 $update = 'promote'; 140 141 foreach ( $user_ids as $id ) { 142 if ( ! current_user_can( 'promote_user', $id ) ) { 143 wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); 144 } 145 146 // The new role of the current user must also have the promote_users cap, be a multisite super admin and must not be empty. 147 if ( $id === $current_user->ID ) { 148 if ( '' === $role ) { 149 wp_die( __( 'Sorry, you cannot remove your own role.' ), 403 ); 150 } 151 152 if ( $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' ) || ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) { 153 continue; 154 } 155 156 $update = 'err_admin_role'; 157 continue; 158 } 159 160 // If the user doesn't already belong to the blog, bail. 161 if ( is_multisite() && ! is_user_member_of_blog( $id ) ) { 162 wp_die( 163 '<h1>' . __( 'An error occurred.' ) . '</h1>' . 164 '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', 165 403 166 ); 167 } 168 169 $user = get_userdata( $id ); 170 171 // If $role is empty, none will be set. 172 $user->set_role( $role ); 173 } 174 175 wp_redirect( add_query_arg( 'update', $update, $redirect ) ); 176 exit; 177 178 case 'dodelete': 179 if ( is_multisite() ) { 180 wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); 181 } 182 183 check_admin_referer( 'delete-users' ); 184 185 if ( empty( $_REQUEST['users'] ) ) { 186 wp_redirect( $redirect ); 187 exit; 188 } 189 190 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 191 192 if ( empty( $_REQUEST['delete_option'] ) ) { 193 $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $user_ids ) . '&error=true' ); 194 $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); 195 wp_redirect( $url ); 196 exit; 197 } 198 199 if ( ! current_user_can( 'delete_users' ) ) { 200 wp_die( __( 'Sorry, you are not allowed to delete users.' ), 403 ); 201 } 202 203 $update = 'del'; 204 $delete_count = 0; 205 206 foreach ( $user_ids as $id ) { 207 if ( ! current_user_can( 'delete_user', $id ) ) { 208 wp_die( __( 'Sorry, you are not allowed to delete that user.' ), 403 ); 209 } 210 211 if ( $id === $current_user->ID ) { 212 $update = 'err_admin_del'; 213 continue; 214 } 215 216 if ( 'reassign' === $_REQUEST['delete_option'][ $id ] && empty( $_REQUEST['reassign_user'][ $id ] ) ) { 217 $update = 'err_missing_reassign'; 218 continue; 219 } 220 221 switch ( $_REQUEST['delete_option'][ $id ] ) { 222 case 'delete': 223 wp_delete_user( $id ); 224 break; 225 case 'reassign': 226 wp_delete_user( $id, $_REQUEST['reassign_user'][ $id ] ); 227 break; 228 } 229 230 ++$delete_count; 231 } 232 233 $redirect = add_query_arg( 234 array( 235 'delete_count' => $delete_count, 236 'update' => $update, 237 ), 238 $redirect 239 ); 240 wp_redirect( $redirect ); 241 exit; 242 243 case 'resetpassword': 244 check_admin_referer( 'bulk-users' ); 245 246 if ( ! current_user_can( 'edit_users' ) ) { 247 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) ); 248 } 249 250 if ( empty( $_REQUEST['users'] ) ) { 251 wp_redirect( $redirect ); 252 exit(); 253 } 254 255 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 256 257 $reset_count = 0; 258 259 foreach ( $user_ids as $id ) { 260 if ( ! current_user_can( 'edit_user', $id ) ) { 261 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 262 } 263 264 if ( $id === $current_user->ID ) { 265 $update = 'err_admin_reset'; 266 continue; 267 } 268 269 // Send the password reset link. 270 $user = get_userdata( $id ); 271 if ( true === retrieve_password( $user->user_login ) ) { 272 ++$reset_count; 273 } 274 } 275 276 $redirect = add_query_arg( 277 array( 278 'reset_count' => $reset_count, 279 'update' => 'resetpassword', 280 ), 281 $redirect 282 ); 283 wp_redirect( $redirect ); 284 exit; 285 286 case 'delete': 287 if ( is_multisite() ) { 288 wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); 289 } 290 291 check_admin_referer( 'bulk-users' ); 292 293 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 294 wp_redirect( $redirect ); 295 exit; 296 } 297 298 if ( ! current_user_can( 'delete_users' ) ) { 299 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); 300 } 301 302 if ( empty( $_REQUEST['users'] ) ) { 303 $user_ids = array( (int) $_REQUEST['user'] ); 304 } else { 305 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 306 } 307 308 $all_user_ids = $user_ids; 309 310 if ( in_array( $current_user->ID, $user_ids, true ) ) { 311 $user_ids = array_diff( $user_ids, array( $current_user->ID ) ); 312 } 313 314 require_once ABSPATH . 'wp-admin/admin-header.php'; 315 ?> 316 <form method="post" name="updateusers" id="updateusers" class="delete-and-reassign-users-form"> 317 <?php wp_nonce_field( 'delete-users' ); ?> 318 <?php echo $referer; ?> 319 320 <div class="wrap"> 321 <h1><?php _e( 'Delete Users' ); ?></h1> 322 323 <?php 324 if ( isset( $_REQUEST['error'] ) ) : 325 wp_admin_notice( 326 '<strong>' . __( 'Error:' ) . '</strong> ' . __( 'Please select an option.' ), 327 array( 328 'additional_classes' => array( 'error' ), 329 ) 330 ); 331 endif; 332 ?> 333 334 <?php if ( 1 === count( $all_user_ids ) ) : ?> 335 <p><?php _e( 'You have specified this user for deletion:' ); ?></p> 336 <?php else : ?> 337 <p><?php _e( 'You have specified these users for deletion:' ); ?></p> 338 <?php endif; ?> 339 340 <ul> 341 <?php 342 /** 343 * @global wpdb $wpdb WordPress database abstraction object. 344 */ 345 global $wpdb; 346 347 $go_delete = 0; 348 $users_have_content = false; 349 350 foreach ( $all_user_ids as $id ) { 351 $user = get_userdata( $id ); 352 353 if ( $id === $current_user->ID ) { 354 echo '<li>'; 355 printf( 356 /* translators: 1: User ID, 2: User login. */ 357 __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), 358 $id, 359 $user->user_login 360 ); 361 echo "</li>\n"; 362 } else { 363 echo '<li>'; 364 printf( 365 '<input type="hidden" name="users[]" value="%s" />', 366 esc_attr( $id ) 367 ); 368 369 /** 370 * Filters whether the users being deleted have additional content 371 * associated with them outside of the `post_author` and `link_owner` relationships. 372 * 373 * @since 5.2.0 374 * 375 * @param bool $users_have_additional_content Whether the users have additional content. Default false. 376 * @param int[] $user_ids Array of IDs for users being deleted. 377 */ 378 $user_has_content = (bool) apply_filters( 'users_have_additional_content', false, array( $id ) ); 379 380 if ( ! $user_has_content ) { 381 if ( $wpdb->get_var( 382 $wpdb->prepare( 383 "SELECT ID FROM {$wpdb->posts} 384 WHERE post_author = %d 385 LIMIT 1", 386 $id 387 ) 388 ) ) { 389 $user_has_content = true; 390 } elseif ( $wpdb->get_var( 391 $wpdb->prepare( 392 "SELECT link_id FROM {$wpdb->links} 393 WHERE link_owner = %d 394 LIMIT 1", 395 $id 396 ) 397 ) ) { 398 $user_has_content = true; 399 } 400 } 401 402 if ( ! $user_has_content ) { 403 ?> 404 <input type="hidden" name="delete_option[<?php echo esc_attr( $id ); ?>]" value="delete" required /> 405 <p> 406 <?php 407 printf( 408 /* translators: 1: User login. 2: User ID */ 409 __( '%1$s (ID #%2$s): This user does not have any content.' ), 410 '<strong>' . $user->user_login . '</strong>', 411 $id 412 ); 413 ?> 414 </p> 415 <?php 416 } else { 417 ?> 418 <fieldset> 419 <legend> 420 <?php 421 printf( 422 /* translators: 1: User login, 2: User ID. */ 423 __( '%1$s (ID #%2$s): What should be done with the content owned by this user?' ), 424 '<strong>' . $user->user_login . '</strong>', 425 $id 426 ); 427 ?> 428 </legend> 429 430 <ul> 431 <li> 432 <input type="radio" id="delete_option_<?php echo esc_attr( $id ); ?>" name="delete_option[<?php echo esc_attr( $id ); ?>]" value="delete" required /> 433 <label for="delete_option_<?php echo esc_attr( $id ); ?>"><?php _e( 'Delete all content.' ); ?></label> 434 </li> 435 <li> 436 <input type="radio" id="reassign_option_<?php echo esc_attr( $id ); ?>" name="delete_option[<?php echo esc_attr( $id ); ?>]" value="reassign" required /> 437 <label for="reassign_option_<?php echo esc_attr( $id ); ?>"><?php _e( 'Attribute all content to another user.' ); ?></label> 438 439 <label for="reassign_user_<?php echo esc_attr( $id ); ?>" class="screen-reader-text"><?php _e( 'Select a user to attribute the content to.' ); ?></label> 440 <?php 441 wp_dropdown_users( 442 array( 443 'show_option_none' => __( 'Select a user' ), 444 'option_none_value' => '', 445 'name' => 'reassign_user[' . $id . ']', 446 'id' => 'reassign_user_' . $id, 447 'exclude' => $user_ids, 448 'show' => 'display_name_with_login', 449 ) 450 ); 451 ?> 452 </li> 453 </ul> 454 </fieldset> 455 <?php 456 $users_have_content = true; 457 } 458 459 echo "</li>\n"; 460 461 ++$go_delete; 462 } 463 } 464 ?> 465 </ul> 466 467 <?php 468 if ( $go_delete ) : 469 /** 470 * Fires at the end of the delete users form prior to the confirm button. 471 * 472 * @since 4.0.0 473 * @since 4.5.0 The `$user_ids` parameter was added. 474 * 475 * @param WP_User $current_user WP_User object for the current user. 476 * @param int[] $user_ids Array of IDs for users being deleted. 477 */ 478 do_action( 'delete_user_form', $current_user, $user_ids ); 479 ?> 480 <input type="hidden" name="action" value="dodelete" /> 481 <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> 482 483 <?php else : ?> 484 485 <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> 486 487 <?php endif; ?> 488 </div><!-- .wrap --> 489 </form><!-- #updateusers --> 490 <?php 491 492 break; 493 494 case 'doremove': 495 check_admin_referer( 'remove-users' ); 496 497 if ( ! is_multisite() ) { 498 wp_die( __( 'You cannot remove users.' ), 400 ); 499 } 500 501 if ( empty( $_REQUEST['users'] ) ) { 502 wp_redirect( $redirect ); 503 exit; 504 } 505 506 if ( ! current_user_can( 'remove_users' ) ) { 507 wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 ); 508 } 509 510 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 511 $update = 'remove'; 512 513 foreach ( $user_ids as $id ) { 514 if ( ! current_user_can( 'remove_user', $id ) ) { 515 $update = 'err_admin_remove'; 516 continue; 517 } 518 519 remove_user_from_blog( $id, $blog_id ); 520 } 521 522 $redirect = add_query_arg( array( 'update' => $update ), $redirect ); 523 wp_redirect( $redirect ); 524 exit; 525 526 case 'remove': 527 check_admin_referer( 'bulk-users' ); 528 529 if ( ! is_multisite() ) { 530 wp_die( __( 'You cannot remove users.' ), 400 ); 531 } 532 533 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 534 wp_redirect( $redirect ); 535 exit; 536 } 537 538 if ( ! current_user_can( 'remove_users' ) ) { 539 $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); 540 } 541 542 if ( empty( $_REQUEST['users'] ) ) { 543 $user_ids = array( (int) $_REQUEST['user'] ); 544 } else { 545 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 546 } 547 548 require_once ABSPATH . 'wp-admin/admin-header.php'; 549 ?> 550 <form method="post" name="updateusers" id="updateusers"> 551 <?php wp_nonce_field( 'remove-users' ); ?> 552 <?php echo $referer; ?> 553 554 <div class="wrap"> 555 <h1><?php _e( 'Remove Users from Site' ); ?></h1> 556 557 <?php if ( 1 === count( $user_ids ) ) : ?> 558 <p><?php _e( 'You have specified this user for removal:' ); ?></p> 559 <?php else : ?> 560 <p><?php _e( 'You have specified these users for removal:' ); ?></p> 561 <?php endif; ?> 562 563 <ul> 564 <?php 565 $go_remove = false; 566 567 foreach ( $user_ids as $id ) { 568 $user = get_userdata( $id ); 569 570 if ( ! current_user_can( 'remove_user', $id ) ) { 571 echo '<li>'; 572 printf( 573 /* translators: 1: User ID, 2: User login. */ 574 __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), 575 $id, 576 $user->user_login 577 ); 578 echo "</li>\n"; 579 } else { 580 echo '<li>'; 581 printf( 582 '<input type="hidden" name="users[]" value="%s" />', 583 esc_attr( $id ) 584 ); 585 printf( 586 /* translators: 1: User ID, 2: User login. */ 587 __( 'ID #%1$s: %2$s' ), 588 $id, 589 $user->user_login 590 ); 591 echo "</li>\n"; 592 593 $go_remove = true; 594 } 595 } 596 ?> 597 </ul> 598 599 <?php if ( $go_remove ) : ?> 600 601 <input type="hidden" name="action" value="doremove" /> 602 <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> 603 604 <?php else : ?> 605 606 <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> 607 608 <?php endif; ?> 609 </div><!-- .wrap --> 610 </form><!-- #updateusers --> 611 <?php 612 613 break; 614 615 default: 616 if ( ! empty( $_GET['_wp_http_referer'] ) ) { 617 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); 618 exit; 619 } 620 621 if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { 622 $screen = get_current_screen()->id; 623 $sendback = wp_get_referer(); 624 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 625 626 /** This action is documented in wp-admin/edit.php */ 627 $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 628 629 wp_safe_redirect( $sendback ); 630 exit; 631 } 632 633 $wp_list_table->prepare_items(); 634 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 635 636 if ( $pagenum > $total_pages && $total_pages > 0 ) { 637 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 638 exit; 639 } 640 641 require_once ABSPATH . 'wp-admin/admin-header.php'; 642 643 $messages = array(); 644 if ( isset( $_GET['update'] ) ) : 645 $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; 646 647 switch ( $_GET['update'] ) { 648 case 'del': 649 case 'del_many': 650 if ( 1 === $delete_count ) { 651 $message = __( 'User deleted.' ); 652 } else { 653 /* translators: %s: Number of users. */ 654 $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); 655 } 656 $message = sprintf( $message, number_format_i18n( $delete_count ) ); 657 $messages[] = wp_get_admin_notice( 658 $message, 659 array( 660 'id' => 'message', 661 'additional_classes' => array( 'updated' ), 662 'dismissible' => true, 663 ) 664 ); 665 break; 666 case 'add': 667 $message = __( 'New user created.' ); 668 $user_id = $_GET['id'] ?? false; 669 if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { 670 $message .= sprintf( 671 ' <a href="%1$s">%2$s</a>', 672 esc_url( 673 add_query_arg( 674 'wp_http_referer', 675 urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 676 self_admin_url( 'user-edit.php?user_id=' . $user_id ) 677 ) 678 ), 679 __( 'Edit user' ) 680 ); 681 } 682 683 $messages[] = wp_get_admin_notice( 684 $message, 685 array( 686 'id' => 'message', 687 'additional_classes' => array( 'updated' ), 688 'dismissible' => true, 689 ) 690 ); 691 break; 692 case 'resetpassword': 693 $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; 694 if ( 1 === $reset_count ) { 695 $message = __( 'Password reset link sent.' ); 696 } else { 697 /* translators: %s: Number of users. */ 698 $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); 699 } 700 $message = sprintf( $message, number_format_i18n( $reset_count ) ); 701 $messages[] = wp_get_admin_notice( 702 $message, 703 array( 704 'id' => 'message', 705 'additional_classes' => array( 'updated' ), 706 'dismissible' => true, 707 ) 708 ); 709 break; 710 case 'promote': 711 $messages[] = wp_get_admin_notice( 712 __( 'Changed roles.' ), 713 array( 714 'id' => 'message', 715 'additional_classes' => array( 'updated' ), 716 'dismissible' => true, 717 ) 718 ); 719 break; 720 case 'err_admin_role': 721 $messages[] = wp_get_admin_notice( 722 __( 'You cannot change your own role to one that does not allow managing other users. Your role was not changed.' ), 723 array( 724 'id' => 'message', 725 'additional_classes' => array( 'error' ), 726 'dismissible' => true, 727 ) 728 ); 729 if ( $delete_count > 0 ) { 730 $messages[] = wp_get_admin_notice( 731 __( 'Other user roles have been changed.' ), 732 array( 733 'id' => 'message', 734 'additional_classes' => array( 'updated' ), 735 'dismissible' => true, 736 ) 737 ); 738 } 739 break; 740 case 'err_admin_del': 741 $messages[] = wp_get_admin_notice( 742 __( 'You cannot delete the current user.' ), 743 array( 744 'id' => 'message', 745 'additional_classes' => array( 'error' ), 746 'dismissible' => true, 747 ) 748 ); 749 if ( $delete_count > 0 ) { 750 $messages[] = wp_get_admin_notice( 751 __( 'Other users have been deleted.' ), 752 array( 753 'id' => 'message', 754 'additional_classes' => array( 'updated' ), 755 'dismissible' => true, 756 ) 757 ); 758 } 759 break; 760 case 'err_missing_reassign': 761 $messages[] = wp_get_admin_notice( 762 __( 'Users could not be deleted because no user was selected for content reassignment.' ), 763 array( 764 'id' => 'message', 765 'additional_classes' => array( 'error' ), 766 'dismissible' => true, 767 ) 768 ); 769 if ( $delete_count > 0 ) { 770 $messages[] = wp_get_admin_notice( 771 __( 'Other users have been deleted.' ), 772 array( 773 'id' => 'message', 774 'additional_classes' => array( 'updated' ), 775 'dismissible' => true, 776 ) 777 ); 778 } 779 break; 780 case 'remove': 781 $messages[] = wp_get_admin_notice( 782 __( 'User removed from this site.' ), 783 array( 784 'id' => 'message', 785 'additional_classes' => array( 'updated', 'fade' ), 786 'dismissible' => true, 787 ) 788 ); 789 break; 790 case 'err_admin_remove': 791 $messages[] = wp_get_admin_notice( 792 __( 'You cannot remove the current user.' ), 793 array( 794 'id' => 'message', 795 'additional_classes' => array( 'error' ), 796 'dismissible' => true, 797 ) 798 ); 799 $messages[] = wp_get_admin_notice( 800 __( 'Other users have been removed.' ), 801 array( 802 'id' => 'message', 803 'additional_classes' => array( 'updated', 'fade' ), 804 'dismissible' => true, 805 ) 806 ); 807 break; 808 } 809 endif; 810 ?> 811 812 <?php 813 if ( isset( $errors ) && is_wp_error( $errors ) ) : 814 $error_message = ''; 815 foreach ( $errors->get_error_messages() as $err ) { 816 $error_message .= "<li>$err</li>\n"; 817 } 818 wp_admin_notice( 819 '<ul>' . $error_message . '</ul>', 820 array( 821 'additional_classes' => array( 'error' ), 822 ) 823 ); 824 endif; 825 826 if ( ! empty( $messages ) ) { 827 foreach ( $messages as $msg ) { 828 echo $msg; 829 } 830 } 831 ?> 832 833 <div class="wrap"> 834 <h1 class="wp-heading-inline"> 835 <?php echo esc_html( $title ); ?> 836 </h1> 837 838 <?php 839 if ( current_user_can( 'create_users' ) ) { 840 printf( 841 '<a href="%1$s" class="page-title-action">%2$s</a>', 842 esc_url( admin_url( 'user-new.php' ) ), 843 esc_html__( 'Add User' ) 844 ); 845 } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { 846 printf( 847 '<a href="%1$s" class="page-title-action">%2$s</a>', 848 esc_url( admin_url( 'user-new.php' ) ), 849 esc_html__( 'Add Existing User' ) 850 ); 851 } 852 853 if ( strlen( $usersearch ) ) { 854 echo '<span class="subtitle">'; 855 printf( 856 /* translators: %s: Search query. */ 857 __( 'Search results for: %s' ), 858 '<strong>' . esc_html( $usersearch ) . '</strong>' 859 ); 860 echo '</span>'; 861 } 862 ?> 863 864 <hr class="wp-header-end"> 865 866 <?php $wp_list_table->views(); ?> 867 868 <form method="get"> 869 870 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 871 872 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> 873 <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> 874 <?php } ?> 875 876 <?php $wp_list_table->display(); ?> 877 878 </form> 879 880 <div class="clear"></div> 881 </div><!-- .wrap --> 882 <?php 883 break; 884 885 } // End of the $doaction switch. 886 887 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Sep 6 08:20:27 2026 | Cross-referenced by PHPXref |