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