| [ 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 switch ( $_REQUEST['delete_option'] ) { 217 case 'delete': 218 wp_delete_user( $id ); 219 break; 220 case 'reassign': 221 wp_delete_user( $id, $_REQUEST['reassign_user'] ); 222 break; 223 } 224 225 ++$delete_count; 226 } 227 228 $redirect = add_query_arg( 229 array( 230 'delete_count' => $delete_count, 231 'update' => $update, 232 ), 233 $redirect 234 ); 235 wp_redirect( $redirect ); 236 exit; 237 238 case 'resetpassword': 239 check_admin_referer( 'bulk-users' ); 240 241 if ( ! current_user_can( 'edit_users' ) ) { 242 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) ); 243 } 244 245 if ( empty( $_REQUEST['users'] ) ) { 246 wp_redirect( $redirect ); 247 exit(); 248 } 249 250 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 251 252 $reset_count = 0; 253 254 foreach ( $user_ids as $id ) { 255 if ( ! current_user_can( 'edit_user', $id ) ) { 256 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 257 } 258 259 if ( $id === $current_user->ID ) { 260 $update = 'err_admin_reset'; 261 continue; 262 } 263 264 // Send the password reset link. 265 $user = get_userdata( $id ); 266 if ( true === retrieve_password( $user->user_login ) ) { 267 ++$reset_count; 268 } 269 } 270 271 $redirect = add_query_arg( 272 array( 273 'reset_count' => $reset_count, 274 'update' => 'resetpassword', 275 ), 276 $redirect 277 ); 278 wp_redirect( $redirect ); 279 exit; 280 281 case 'delete': 282 if ( is_multisite() ) { 283 wp_die( __( 'User deletion is not allowed from this screen.' ), 400 ); 284 } 285 286 check_admin_referer( 'bulk-users' ); 287 288 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 289 wp_redirect( $redirect ); 290 exit; 291 } 292 293 if ( ! current_user_can( 'delete_users' ) ) { 294 $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) ); 295 } 296 297 if ( empty( $_REQUEST['users'] ) ) { 298 $user_ids = array( (int) $_REQUEST['user'] ); 299 } else { 300 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 301 } 302 303 $all_user_ids = $user_ids; 304 305 if ( in_array( $current_user->ID, $user_ids, true ) ) { 306 $user_ids = array_diff( $user_ids, array( $current_user->ID ) ); 307 } 308 309 /** 310 * Filters whether the users being deleted have additional content 311 * associated with them outside of the `post_author` and `link_owner` relationships. 312 * 313 * @since 5.2.0 314 * 315 * @param bool $users_have_additional_content Whether the users have additional content. Default false. 316 * @param int[] $user_ids Array of IDs for users being deleted. 317 */ 318 $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $user_ids ); 319 320 if ( $user_ids && ! $users_have_content ) { 321 if ( $wpdb->get_var( 322 "SELECT ID FROM {$wpdb->posts} 323 WHERE post_author IN( " . implode( ',', $user_ids ) . ' ) 324 LIMIT 1' 325 ) ) { 326 $users_have_content = true; 327 } elseif ( $wpdb->get_var( 328 "SELECT link_id FROM {$wpdb->links} 329 WHERE link_owner IN( " . implode( ',', $user_ids ) . ' ) 330 LIMIT 1' 331 ) ) { 332 $users_have_content = true; 333 } 334 } 335 336 if ( $users_have_content ) { 337 add_action( 'admin_head', 'delete_users_add_js' ); 338 } 339 340 require_once ABSPATH . 'wp-admin/admin-header.php'; 341 ?> 342 <form method="post" name="updateusers" id="updateusers"> 343 <?php wp_nonce_field( 'delete-users' ); ?> 344 <?php echo $referer; ?> 345 346 <div class="wrap"> 347 <h1><?php _e( 'Delete Users' ); ?></h1> 348 349 <?php 350 if ( isset( $_REQUEST['error'] ) ) : 351 wp_admin_notice( 352 '<strong>' . __( 'Error:' ) . '</strong> ' . __( 'Please select an option.' ), 353 array( 354 'additional_classes' => array( 'error' ), 355 ) 356 ); 357 endif; 358 ?> 359 360 <?php if ( 1 === count( $all_user_ids ) ) : ?> 361 <p><?php _e( 'You have specified this user for deletion:' ); ?></p> 362 <?php else : ?> 363 <p><?php _e( 'You have specified these users for deletion:' ); ?></p> 364 <?php endif; ?> 365 366 <ul> 367 <?php 368 $go_delete = 0; 369 370 foreach ( $all_user_ids as $id ) { 371 $user = get_userdata( $id ); 372 373 if ( $id === $current_user->ID ) { 374 echo '<li>'; 375 printf( 376 /* translators: 1: User ID, 2: User login. */ 377 __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), 378 $id, 379 $user->user_login 380 ); 381 echo "</li>\n"; 382 } else { 383 echo '<li>'; 384 printf( 385 '<input type="hidden" name="users[]" value="%s" />', 386 esc_attr( $id ) 387 ); 388 printf( 389 /* translators: 1: User ID, 2: User login. */ 390 __( 'ID #%1$s: %2$s' ), 391 $id, 392 $user->user_login 393 ); 394 echo "</li>\n"; 395 396 ++$go_delete; 397 } 398 } 399 ?> 400 </ul> 401 402 <?php 403 if ( $go_delete ) : 404 405 if ( ! $users_have_content ) : 406 ?> 407 <input type="hidden" name="delete_option" value="delete" /> 408 <?php else : ?> 409 <fieldset> 410 <?php if ( 1 === $go_delete ) : ?> 411 <p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> 412 <?php else : ?> 413 <p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> 414 <?php endif; ?> 415 416 <ul style="list-style:none;"> 417 <li> 418 <input type="radio" id="delete_option0" name="delete_option" value="delete" /> 419 <label for="delete_option0"><?php _e( 'Delete all content.' ); ?></label> 420 </li> 421 <li> 422 <input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 423 <label for="delete_option1"><?php _e( 'Attribute all content to:' ); ?></label> 424 <?php 425 wp_dropdown_users( 426 array( 427 'name' => 'reassign_user', 428 'exclude' => $user_ids, 429 'show' => 'display_name_with_login', 430 ) 431 ); 432 ?> 433 </li> 434 </ul> 435 </fieldset> 436 <?php 437 endif; 438 439 /** 440 * Fires at the end of the delete users form prior to the confirm button. 441 * 442 * @since 4.0.0 443 * @since 4.5.0 The `$user_ids` parameter was added. 444 * 445 * @param WP_User $current_user WP_User object for the current user. 446 * @param int[] $user_ids Array of IDs for users being deleted. 447 */ 448 do_action( 'delete_user_form', $current_user, $user_ids ); 449 ?> 450 <input type="hidden" name="action" value="dodelete" /> 451 <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?> 452 453 <?php else : ?> 454 455 <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p> 456 457 <?php endif; ?> 458 </div><!-- .wrap --> 459 </form><!-- #updateusers --> 460 <?php 461 462 break; 463 464 case 'doremove': 465 check_admin_referer( 'remove-users' ); 466 467 if ( ! is_multisite() ) { 468 wp_die( __( 'You cannot remove users.' ), 400 ); 469 } 470 471 if ( empty( $_REQUEST['users'] ) ) { 472 wp_redirect( $redirect ); 473 exit; 474 } 475 476 if ( ! current_user_can( 'remove_users' ) ) { 477 wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 ); 478 } 479 480 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 481 $update = 'remove'; 482 483 foreach ( $user_ids as $id ) { 484 if ( ! current_user_can( 'remove_user', $id ) ) { 485 $update = 'err_admin_remove'; 486 continue; 487 } 488 489 remove_user_from_blog( $id, $blog_id ); 490 } 491 492 $redirect = add_query_arg( array( 'update' => $update ), $redirect ); 493 wp_redirect( $redirect ); 494 exit; 495 496 case 'remove': 497 check_admin_referer( 'bulk-users' ); 498 499 if ( ! is_multisite() ) { 500 wp_die( __( 'You cannot remove users.' ), 400 ); 501 } 502 503 if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) { 504 wp_redirect( $redirect ); 505 exit; 506 } 507 508 if ( ! current_user_can( 'remove_users' ) ) { 509 $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) ); 510 } 511 512 if ( empty( $_REQUEST['users'] ) ) { 513 $user_ids = array( (int) $_REQUEST['user'] ); 514 } else { 515 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 516 } 517 518 require_once ABSPATH . 'wp-admin/admin-header.php'; 519 ?> 520 <form method="post" name="updateusers" id="updateusers"> 521 <?php wp_nonce_field( 'remove-users' ); ?> 522 <?php echo $referer; ?> 523 524 <div class="wrap"> 525 <h1><?php _e( 'Remove Users from Site' ); ?></h1> 526 527 <?php if ( 1 === count( $user_ids ) ) : ?> 528 <p><?php _e( 'You have specified this user for removal:' ); ?></p> 529 <?php else : ?> 530 <p><?php _e( 'You have specified these users for removal:' ); ?></p> 531 <?php endif; ?> 532 533 <ul> 534 <?php 535 $go_remove = false; 536 537 foreach ( $user_ids as $id ) { 538 $user = get_userdata( $id ); 539 540 if ( ! current_user_can( 'remove_user', $id ) ) { 541 echo '<li>'; 542 printf( 543 /* translators: 1: User ID, 2: User login. */ 544 __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), 545 $id, 546 $user->user_login 547 ); 548 echo "</li>\n"; 549 } else { 550 echo '<li>'; 551 printf( 552 '<input type="hidden" name="users[]" value="%s" />', 553 esc_attr( $id ) 554 ); 555 printf( 556 /* translators: 1: User ID, 2: User login. */ 557 __( 'ID #%1$s: %2$s' ), 558 $id, 559 $user->user_login 560 ); 561 echo "</li>\n"; 562 563 $go_remove = true; 564 } 565 } 566 ?> 567 </ul> 568 569 <?php if ( $go_remove ) : ?> 570 571 <input type="hidden" name="action" value="doremove" /> 572 <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?> 573 574 <?php else : ?> 575 576 <p><?php _e( 'There are no valid users selected for removal.' ); ?></p> 577 578 <?php endif; ?> 579 </div><!-- .wrap --> 580 </form><!-- #updateusers --> 581 <?php 582 583 break; 584 585 default: 586 if ( ! empty( $_GET['_wp_http_referer'] ) ) { 587 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); 588 exit; 589 } 590 591 if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) { 592 $screen = get_current_screen()->id; 593 $sendback = wp_get_referer(); 594 $user_ids = array_map( 'intval', (array) $_REQUEST['users'] ); 595 596 /** This action is documented in wp-admin/edit.php */ 597 $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 598 599 wp_safe_redirect( $sendback ); 600 exit; 601 } 602 603 $wp_list_table->prepare_items(); 604 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 605 606 if ( $pagenum > $total_pages && $total_pages > 0 ) { 607 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 608 exit; 609 } 610 611 require_once ABSPATH . 'wp-admin/admin-header.php'; 612 613 $messages = array(); 614 if ( isset( $_GET['update'] ) ) : 615 switch ( $_GET['update'] ) { 616 case 'del': 617 case 'del_many': 618 $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; 619 if ( 1 === $delete_count ) { 620 $message = __( 'User deleted.' ); 621 } else { 622 /* translators: %s: Number of users. */ 623 $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); 624 } 625 $message = sprintf( $message, number_format_i18n( $delete_count ) ); 626 $messages[] = wp_get_admin_notice( 627 $message, 628 array( 629 'id' => 'message', 630 'additional_classes' => array( 'updated' ), 631 'dismissible' => true, 632 ) 633 ); 634 break; 635 case 'add': 636 $message = __( 'New user created.' ); 637 $user_id = $_GET['id'] ?? false; 638 if ( $user_id && current_user_can( 'edit_user', $user_id ) ) { 639 $message .= sprintf( 640 ' <a href="%1$s">%2$s</a>', 641 esc_url( 642 add_query_arg( 643 'wp_http_referer', 644 urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 645 self_admin_url( 'user-edit.php?user_id=' . $user_id ) 646 ) 647 ), 648 __( 'Edit user' ) 649 ); 650 } 651 652 $messages[] = wp_get_admin_notice( 653 $message, 654 array( 655 'id' => 'message', 656 'additional_classes' => array( 'updated' ), 657 'dismissible' => true, 658 ) 659 ); 660 break; 661 case 'resetpassword': 662 $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0; 663 if ( 1 === $reset_count ) { 664 $message = __( 'Password reset link sent.' ); 665 } else { 666 /* translators: %s: Number of users. */ 667 $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count ); 668 } 669 $message = sprintf( $message, number_format_i18n( $reset_count ) ); 670 $messages[] = wp_get_admin_notice( 671 $message, 672 array( 673 'id' => 'message', 674 'additional_classes' => array( 'updated' ), 675 'dismissible' => true, 676 ) 677 ); 678 break; 679 case 'promote': 680 $messages[] = wp_get_admin_notice( 681 __( 'Changed roles.' ), 682 array( 683 'id' => 'message', 684 'additional_classes' => array( 'updated' ), 685 'dismissible' => true, 686 ) 687 ); 688 break; 689 case 'err_admin_role': 690 $messages[] = wp_get_admin_notice( 691 __( 'You cannot change your own role to one that does not allow managing other users. Your role was not changed.' ), 692 array( 693 'id' => 'message', 694 'additional_classes' => array( 'error' ), 695 'dismissible' => true, 696 ) 697 ); 698 $messages[] = wp_get_admin_notice( 699 __( 'Other user roles have been changed.' ), 700 array( 701 'id' => 'message', 702 'additional_classes' => array( 'updated' ), 703 'dismissible' => true, 704 ) 705 ); 706 break; 707 case 'err_admin_del': 708 $messages[] = wp_get_admin_notice( 709 __( 'You cannot delete the current user.' ), 710 array( 711 'id' => 'message', 712 'additional_classes' => array( 'error' ), 713 'dismissible' => true, 714 ) 715 ); 716 $messages[] = wp_get_admin_notice( 717 __( 'Other users have been deleted.' ), 718 array( 719 'id' => 'message', 720 'additional_classes' => array( 'updated' ), 721 'dismissible' => true, 722 ) 723 ); 724 break; 725 case 'remove': 726 $messages[] = wp_get_admin_notice( 727 __( 'User removed from this site.' ), 728 array( 729 'id' => 'message', 730 'additional_classes' => array( 'updated', 'fade' ), 731 'dismissible' => true, 732 ) 733 ); 734 break; 735 case 'err_admin_remove': 736 $messages[] = wp_get_admin_notice( 737 __( 'You cannot remove the current user.' ), 738 array( 739 'id' => 'message', 740 'additional_classes' => array( 'error' ), 741 'dismissible' => true, 742 ) 743 ); 744 $messages[] = wp_get_admin_notice( 745 __( 'Other users have been removed.' ), 746 array( 747 'id' => 'message', 748 'additional_classes' => array( 'updated', 'fade' ), 749 'dismissible' => true, 750 ) 751 ); 752 break; 753 } 754 endif; 755 ?> 756 757 <?php 758 if ( isset( $errors ) && is_wp_error( $errors ) ) : 759 $error_message = ''; 760 foreach ( $errors->get_error_messages() as $err ) { 761 $error_message .= "<li>$err</li>\n"; 762 } 763 wp_admin_notice( 764 '<ul>' . $error_message . '</ul>', 765 array( 766 'additional_classes' => array( 'error' ), 767 ) 768 ); 769 endif; 770 771 if ( ! empty( $messages ) ) { 772 foreach ( $messages as $msg ) { 773 echo $msg; 774 } 775 } 776 ?> 777 778 <div class="wrap"> 779 <h1 class="wp-heading-inline"> 780 <?php echo esc_html( $title ); ?> 781 </h1> 782 783 <?php 784 if ( current_user_can( 'create_users' ) ) { 785 printf( 786 '<a href="%1$s" class="page-title-action">%2$s</a>', 787 esc_url( admin_url( 'user-new.php' ) ), 788 esc_html__( 'Add User' ) 789 ); 790 } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { 791 printf( 792 '<a href="%1$s" class="page-title-action">%2$s</a>', 793 esc_url( admin_url( 'user-new.php' ) ), 794 esc_html__( 'Add Existing User' ) 795 ); 796 } 797 798 if ( strlen( $usersearch ) ) { 799 echo '<span class="subtitle">'; 800 printf( 801 /* translators: %s: Search query. */ 802 __( 'Search results for: %s' ), 803 '<strong>' . esc_html( $usersearch ) . '</strong>' 804 ); 805 echo '</span>'; 806 } 807 ?> 808 809 <hr class="wp-header-end"> 810 811 <?php $wp_list_table->views(); ?> 812 813 <form method="get"> 814 815 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> 816 817 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?> 818 <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" /> 819 <?php } ?> 820 821 <?php $wp_list_table->display(); ?> 822 823 </form> 824 825 <div class="clear"></div> 826 </div><!-- .wrap --> 827 <?php 828 break; 829 830 } // End of the $doaction switch. 831 832 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Apr 25 08:20:11 2026 | Cross-referenced by PHPXref |