[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> users.php (source)

   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 New button at the top of the screen or Add New 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 .= '</ul>';
  64  
  65  get_current_screen()->add_help_tab(
  66      array(
  67          'id'      => 'action-links',
  68          'title'   => __( 'Available Actions' ),
  69          'content' => $help,
  70      )
  71  );
  72  unset( $help );
  73  
  74  get_current_screen()->set_help_sidebar(
  75      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  76      '<p>' . __( '<a href="https://wordpress.org/support/article/users-screen/">Documentation on Managing Users</a>' ) . '</p>' .
  77      '<p>' . __( '<a href="https://wordpress.org/support/article/roles-and-capabilities/">Descriptions of Roles and Capabilities</a>' ) . '</p>' .
  78      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  79  );
  80  
  81  get_current_screen()->set_screen_reader_content(
  82      array(
  83          'heading_views'      => __( 'Filter users list' ),
  84          'heading_pagination' => __( 'Users list navigation' ),
  85          'heading_list'       => __( 'Users list' ),
  86      )
  87  );
  88  
  89  if ( empty( $_REQUEST ) ) {
  90      $referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
  91  } elseif ( isset( $_REQUEST['wp_http_referer'] ) ) {
  92      $redirect = remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), wp_unslash( $_REQUEST['wp_http_referer'] ) );
  93      $referer  = '<input type="hidden" name="wp_http_referer" value="' . esc_attr( $redirect ) . '" />';
  94  } else {
  95      $redirect = 'users.php';
  96      $referer  = '';
  97  }
  98  
  99  $update = '';
 100  
 101  switch ( $wp_list_table->current_action() ) {
 102  
 103      /* Bulk Dropdown menu Role changes */
 104      case 'promote':
 105          check_admin_referer( 'bulk-users' );
 106  
 107          if ( ! current_user_can( 'promote_users' ) ) {
 108              wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
 109          }
 110  
 111          if ( empty( $_REQUEST['users'] ) ) {
 112              wp_redirect( $redirect );
 113              exit;
 114          }
 115  
 116          $editable_roles = get_editable_roles();
 117          $role           = $_REQUEST['new_role'];
 118  
 119          // Mocking the `none` role so we are able to save it to the database
 120          $editable_roles['none'] = array(
 121              'name' => __( '&mdash; No role for this site &mdash;' ),
 122          );
 123  
 124          if ( ! $role || empty( $editable_roles[ $role ] ) ) {
 125              wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
 126          }
 127  
 128          if ( 'none' === $role ) {
 129              $role = '';
 130          }
 131  
 132          $userids = $_REQUEST['users'];
 133          $update  = 'promote';
 134          foreach ( $userids as $id ) {
 135              $id = (int) $id;
 136  
 137              if ( ! current_user_can( 'promote_user', $id ) ) {
 138                  wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
 139              }
 140  
 141              // The new role of the current user must also have the promote_users cap or be a multisite super admin.
 142              if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' )
 143              && ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) {
 144                      $update = 'err_admin_role';
 145                      continue;
 146              }
 147  
 148              // If the user doesn't already belong to the blog, bail.
 149              if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
 150                  wp_die(
 151                      '<h1>' . __( 'Something went wrong.' ) . '</h1>' .
 152                      '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>',
 153                      403
 154                  );
 155              }
 156  
 157              $user = get_userdata( $id );
 158              $user->set_role( $role );
 159          }
 160  
 161          wp_redirect( add_query_arg( 'update', $update, $redirect ) );
 162          exit;
 163  
 164      case 'dodelete':
 165          if ( is_multisite() ) {
 166              wp_die( __( 'User deletion is not allowed from this screen.' ), 400 );
 167          }
 168  
 169          check_admin_referer( 'delete-users' );
 170  
 171          if ( empty( $_REQUEST['users'] ) ) {
 172              wp_redirect( $redirect );
 173              exit;
 174          }
 175  
 176          $userids = array_map( 'intval', (array) $_REQUEST['users'] );
 177  
 178          if ( empty( $_REQUEST['delete_option'] ) ) {
 179              $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' );
 180              $url = str_replace( '&amp;', '&', wp_nonce_url( $url, 'bulk-users' ) );
 181              wp_redirect( $url );
 182              exit;
 183          }
 184  
 185          if ( ! current_user_can( 'delete_users' ) ) {
 186              wp_die( __( 'Sorry, you are not allowed to delete users.' ), 403 );
 187          }
 188  
 189          $update       = 'del';
 190          $delete_count = 0;
 191  
 192          foreach ( $userids as $id ) {
 193              if ( ! current_user_can( 'delete_user', $id ) ) {
 194                  wp_die( __( 'Sorry, you are not allowed to delete that user.' ), 403 );
 195              }
 196  
 197              if ( $id == $current_user->ID ) {
 198                  $update = 'err_admin_del';
 199                  continue;
 200              }
 201              switch ( $_REQUEST['delete_option'] ) {
 202                  case 'delete':
 203                      wp_delete_user( $id );
 204                      break;
 205                  case 'reassign':
 206                      wp_delete_user( $id, $_REQUEST['reassign_user'] );
 207                      break;
 208              }
 209              ++$delete_count;
 210          }
 211  
 212          $redirect = add_query_arg(
 213              array(
 214                  'delete_count' => $delete_count,
 215                  'update'       => $update,
 216              ),
 217              $redirect
 218          );
 219          wp_redirect( $redirect );
 220          exit;
 221  
 222      case 'resetpassword':
 223          check_admin_referer( 'bulk-users' );
 224          if ( ! current_user_can( 'edit_users' ) ) {
 225              $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to edit users.' ) );
 226          }
 227          if ( empty( $_REQUEST['users'] ) ) {
 228              wp_redirect( $redirect );
 229              exit();
 230          }
 231          $userids = array_map( 'intval', (array) $_REQUEST['users'] );
 232  
 233          $reset_count = 0;
 234  
 235          foreach ( $userids as $id ) {
 236              if ( ! current_user_can( 'edit_user', $id ) ) {
 237                  wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
 238              }
 239  
 240              if ( $id === $current_user->ID ) {
 241                  $update = 'err_admin_reset';
 242                  continue;
 243              }
 244  
 245              // Send the password reset link.
 246              $user = get_userdata( $id );
 247              if ( retrieve_password( $user->user_login ) ) {
 248                  ++$reset_count;
 249              }
 250          }
 251  
 252          $redirect = add_query_arg(
 253              array(
 254                  'reset_count' => $reset_count,
 255                  'update'      => 'resetpassword',
 256              ),
 257              $redirect
 258          );
 259          wp_redirect( $redirect );
 260          exit;
 261  
 262      case 'delete':
 263          if ( is_multisite() ) {
 264              wp_die( __( 'User deletion is not allowed from this screen.' ), 400 );
 265          }
 266  
 267          check_admin_referer( 'bulk-users' );
 268  
 269          if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
 270              wp_redirect( $redirect );
 271              exit;
 272          }
 273  
 274          if ( ! current_user_can( 'delete_users' ) ) {
 275              $errors = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to delete users.' ) );
 276          }
 277  
 278          if ( empty( $_REQUEST['users'] ) ) {
 279              $userids = array( (int) $_REQUEST['user'] );
 280          } else {
 281              $userids = array_map( 'intval', (array) $_REQUEST['users'] );
 282          }
 283  
 284          $all_userids = $userids;
 285  
 286          if ( in_array( $current_user->ID, $userids, true ) ) {
 287              $userids = array_diff( $userids, array( $current_user->ID ) );
 288          }
 289  
 290          /**
 291           * Filters whether the users being deleted have additional content
 292           * associated with them outside of the `post_author` and `link_owner` relationships.
 293           *
 294           * @since 5.2.0
 295           *
 296           * @param bool  $users_have_additional_content Whether the users have additional content. Default false.
 297           * @param int[] $userids                       Array of IDs for users being deleted.
 298           */
 299          $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
 300  
 301          if ( $userids && ! $users_have_content ) {
 302              if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
 303                  $users_have_content = true;
 304              } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
 305                  $users_have_content = true;
 306              }
 307          }
 308  
 309          if ( $users_have_content ) {
 310              add_action( 'admin_head', 'delete_users_add_js' );
 311          }
 312  
 313          require_once ABSPATH . 'wp-admin/admin-header.php';
 314          ?>
 315      <form method="post" name="updateusers" id="updateusers">
 316          <?php wp_nonce_field( 'delete-users' ); ?>
 317          <?php echo $referer; ?>
 318  
 319  <div class="wrap">
 320  <h1><?php _e( 'Delete Users' ); ?></h1>
 321          <?php if ( isset( $_REQUEST['error'] ) ) : ?>
 322      <div class="error">
 323          <p><strong><?php _e( 'Error:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
 324      </div>
 325          <?php endif; ?>
 326  
 327          <?php if ( 1 === count( $all_userids ) ) : ?>
 328      <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
 329          <?php else : ?>
 330      <p><?php _e( 'You have specified these users for deletion:' ); ?></p>
 331          <?php endif; ?>
 332  
 333  <ul>
 334          <?php
 335          $go_delete = 0;
 336          foreach ( $all_userids as $id ) {
 337              $user = get_userdata( $id );
 338              if ( $id == $current_user->ID ) {
 339                  /* translators: 1: User ID, 2: User login. */
 340                  echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n";
 341              } else {
 342                  /* translators: 1: User ID, 2: User login. */
 343                  echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
 344                  $go_delete++;
 345              }
 346          }
 347          ?>
 348      </ul>
 349          <?php
 350          if ( $go_delete ) :
 351  
 352              if ( ! $users_have_content ) :
 353                  ?>
 354              <input type="hidden" name="delete_option" value="delete" />
 355              <?php else : ?>
 356                  <?php if ( 1 == $go_delete ) : ?>
 357              <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
 358          <?php else : ?>
 359              <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
 360          <?php endif; ?>
 361          <ul style="list-style:none;">
 362              <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
 363                  <?php _e( 'Delete all content.' ); ?></label></li>
 364              <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
 365                  <?php
 366                  echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
 367                  wp_dropdown_users(
 368                      array(
 369                          'name'    => 'reassign_user',
 370                          'exclude' => $userids,
 371                          'show'    => 'display_name_with_login',
 372                      )
 373                  );
 374                  ?>
 375              </li>
 376          </ul></fieldset>
 377                  <?php
 378      endif;
 379              /**
 380               * Fires at the end of the delete users form prior to the confirm button.
 381               *
 382               * @since 4.0.0
 383               * @since 4.5.0 The `$userids` parameter was added.
 384               *
 385               * @param WP_User $current_user WP_User object for the current user.
 386               * @param int[]   $userids      Array of IDs for users being deleted.
 387               */
 388              do_action( 'delete_user_form', $current_user, $userids );
 389              ?>
 390      <input type="hidden" name="action" value="dodelete" />
 391              <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?>
 392      <?php else : ?>
 393      <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p>
 394      <?php endif; ?>
 395      </div>
 396      </form>
 397          <?php
 398  
 399          break;
 400  
 401      case 'doremove':
 402          check_admin_referer( 'remove-users' );
 403  
 404          if ( ! is_multisite() ) {
 405              wp_die( __( 'You can&#8217;t remove users.' ), 400 );
 406          }
 407  
 408          if ( empty( $_REQUEST['users'] ) ) {
 409              wp_redirect( $redirect );
 410              exit;
 411          }
 412  
 413          if ( ! current_user_can( 'remove_users' ) ) {
 414              wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 );
 415          }
 416  
 417          $userids = $_REQUEST['users'];
 418  
 419          $update = 'remove';
 420          foreach ( $userids as $id ) {
 421              $id = (int) $id;
 422              if ( ! current_user_can( 'remove_user', $id ) ) {
 423                  $update = 'err_admin_remove';
 424                  continue;
 425              }
 426              remove_user_from_blog( $id, $blog_id );
 427          }
 428  
 429          $redirect = add_query_arg( array( 'update' => $update ), $redirect );
 430          wp_redirect( $redirect );
 431          exit;
 432  
 433      case 'remove':
 434          check_admin_referer( 'bulk-users' );
 435  
 436          if ( ! is_multisite() ) {
 437              wp_die( __( 'You can&#8217;t remove users.' ), 400 );
 438          }
 439  
 440          if ( empty( $_REQUEST['users'] ) && empty( $_REQUEST['user'] ) ) {
 441              wp_redirect( $redirect );
 442              exit;
 443          }
 444  
 445          if ( ! current_user_can( 'remove_users' ) ) {
 446              $error = new WP_Error( 'edit_users', __( 'Sorry, you are not allowed to remove users.' ) );
 447          }
 448  
 449          if ( empty( $_REQUEST['users'] ) ) {
 450              $userids = array( (int) $_REQUEST['user'] );
 451          } else {
 452              $userids = $_REQUEST['users'];
 453          }
 454  
 455          require_once ABSPATH . 'wp-admin/admin-header.php';
 456          ?>
 457      <form method="post" name="updateusers" id="updateusers">
 458          <?php wp_nonce_field( 'remove-users' ); ?>
 459          <?php echo $referer; ?>
 460  
 461  <div class="wrap">
 462  <h1><?php _e( 'Remove Users from Site' ); ?></h1>
 463  
 464          <?php if ( 1 === count( $userids ) ) : ?>
 465      <p><?php _e( 'You have specified this user for removal:' ); ?></p>
 466          <?php else : ?>
 467      <p><?php _e( 'You have specified these users for removal:' ); ?></p>
 468          <?php endif; ?>
 469  
 470  <ul>
 471          <?php
 472          $go_remove = false;
 473          foreach ( $userids as $id ) {
 474              $id   = (int) $id;
 475              $user = get_userdata( $id );
 476              if ( ! current_user_can( 'remove_user', $id ) ) {
 477                  /* translators: 1: User ID, 2: User login. */
 478                  echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n";
 479              } else {
 480                  /* translators: 1: User ID, 2: User login. */
 481                  echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
 482                  $go_remove = true;
 483              }
 484          }
 485          ?>
 486      </ul>
 487          <?php if ( $go_remove ) : ?>
 488          <input type="hidden" name="action" value="doremove" />
 489              <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?>
 490      <?php else : ?>
 491      <p><?php _e( 'There are no valid users selected for removal.' ); ?></p>
 492      <?php endif; ?>
 493      </div>
 494      </form>
 495          <?php
 496  
 497          break;
 498  
 499      default:
 500          if ( ! empty( $_GET['_wp_http_referer'] ) ) {
 501              wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
 502              exit;
 503          }
 504  
 505          if ( $wp_list_table->current_action() && ! empty( $_REQUEST['users'] ) ) {
 506              $screen   = get_current_screen()->id;
 507              $sendback = wp_get_referer();
 508              $userids  = $_REQUEST['users'];
 509  
 510              /** This action is documented in wp-admin/edit.php */
 511              $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $wp_list_table->current_action(), $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 512  
 513              wp_safe_redirect( $sendback );
 514              exit;
 515          }
 516  
 517          $wp_list_table->prepare_items();
 518          $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
 519          if ( $pagenum > $total_pages && $total_pages > 0 ) {
 520              wp_redirect( add_query_arg( 'paged', $total_pages ) );
 521              exit;
 522          }
 523  
 524          require_once ABSPATH . 'wp-admin/admin-header.php';
 525  
 526          $messages = array();
 527          if ( isset( $_GET['update'] ) ) :
 528              switch ( $_GET['update'] ) {
 529                  case 'del':
 530                  case 'del_many':
 531                      $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0;
 532                      if ( 1 == $delete_count ) {
 533                          $message = __( 'User deleted.' );
 534                      } else {
 535                          /* translators: %s: Number of users. */
 536                          $message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
 537                      }
 538                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
 539                      break;
 540                  case 'add':
 541                      $message = __( 'New user created.' );
 542  
 543                      $user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
 544                      if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
 545                          $message .= sprintf(
 546                              ' <a href="%s">%s</a>',
 547                              esc_url(
 548                                  add_query_arg(
 549                                      'wp_http_referer',
 550                                      urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
 551                                      self_admin_url( 'user-edit.php?user_id=' . $user_id )
 552                                  )
 553                              ),
 554                              __( 'Edit user' )
 555                          );
 556                      }
 557  
 558                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>';
 559                      break;
 560                  case 'resetpassword':
 561                      $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0;
 562                      if ( 1 === $reset_count ) {
 563                          $message = __( 'Password reset link sent.' );
 564                      } else {
 565                          /* translators: %s: Number of users. */
 566                          $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count );
 567                      }
 568                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $reset_count ) ) . '</p></div>';
 569                      break;
 570                  case 'promote':
 571                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>';
 572                      break;
 573                  case 'err_admin_role':
 574                      $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'The current user&#8217;s role must have user editing capabilities.' ) . '</p></div>';
 575                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other user roles have been changed.' ) . '</p></div>';
 576                      break;
 577                  case 'err_admin_del':
 578                      $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'You can&#8217;t delete the current user.' ) . '</p></div>';
 579                      $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Other users have been deleted.' ) . '</p></div>';
 580                      break;
 581                  case 'remove':
 582                      $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'User removed from this site.' ) . '</p></div>';
 583                      break;
 584                  case 'err_admin_remove':
 585                      $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( "You can't remove the current user." ) . '</p></div>';
 586                      $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __( 'Other users have been removed.' ) . '</p></div>';
 587                      break;
 588              }
 589          endif;
 590          ?>
 591  
 592          <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
 593          <div class="error">
 594              <ul>
 595              <?php
 596              foreach ( $errors->get_error_messages() as $err ) {
 597                  echo "<li>$err</li>\n";
 598              }
 599              ?>
 600              </ul>
 601          </div>
 602              <?php
 603      endif;
 604  
 605          if ( ! empty( $messages ) ) {
 606              foreach ( $messages as $msg ) {
 607                  echo $msg;
 608              }
 609          }
 610          ?>
 611  
 612      <div class="wrap">
 613      <h1 class="wp-heading-inline">
 614          <?php
 615          echo esc_html( $title );
 616          ?>
 617  </h1>
 618  
 619          <?php
 620          if ( current_user_can( 'create_users' ) ) {
 621              ?>
 622      <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
 623  <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
 624      <a href="<?php echo esc_url( admin_url( 'user-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
 625              <?php
 626  }
 627  
 628  if ( strlen( $usersearch ) ) {
 629      echo '<span class="subtitle">';
 630      printf(
 631          /* translators: %s: Search query. */
 632          __( 'Search results for: %s' ),
 633          '<strong>' . esc_html( $usersearch ) . '</strong>'
 634      );
 635      echo '</span>';
 636  }
 637  ?>
 638  
 639  <hr class="wp-header-end">
 640  
 641          <?php $wp_list_table->views(); ?>
 642  
 643  <form method="get">
 644  
 645          <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
 646  
 647          <?php if ( ! empty( $_REQUEST['role'] ) ) { ?>
 648  <input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" />
 649  <?php } ?>
 650  
 651          <?php $wp_list_table->display(); ?>
 652  </form>
 653  
 654  <div class="clear"></div>
 655  </div>
 656          <?php
 657          break;
 658  
 659  } // End of the $doaction switch.
 660  
 661  require_once ABSPATH . 'wp-admin/admin-footer.php';


Generated: Sun Dec 5 01:00:03 2021 Cross-referenced by PHPXref 0.7.1