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