WordPress.org

Make WordPress Core

Ticket #36196: 36196.diff

File 36196.diff, 2.0 KB (added by flixos90, 4 years ago)

show users with no role

  • src/wp-admin/includes/class-wp-users-list-table.php

     
    9898                        $args = array(
    9999                                'number' => $users_per_page,
    100100                                'offset' => ( $paged-1 ) * $users_per_page,
    101                                 'include' => wp_get_users_with_no_role(),
     101                                'include' => wp_get_users_with_no_role( $this->site_id ),
    102102                                'search' => $usersearch,
    103103                                'fields' => 'all_with_meta'
    104104                        );
     
    354354                        $post_counts = count_many_users_posts( array_keys( $this->items ) );
    355355
    356356                foreach ( $this->items as $userid => $user_object ) {
    357                         if ( is_multisite() && empty( $user_object->allcaps ) )
    358                                 continue;
    359 
    360357                        echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
    361358                }
    362359        }
  • src/wp-includes/user.php

     
    24062406/**
    24072407 * Get the user IDs of all users with no role on this site.
    24082408 *
    2409  * This function returns an empty array when used on Multisite.
    2410  *
    24112409 * @since 4.4.0
     2410 * @since 4.6.0 The `$site_id` parameter was added to support multisite.
    24122411 *
     2412 * @param int|null $site_id Optional. The site ID to get users with no role for. Defaults to the current site.
     2413 *
    24132414 * @return array Array of user IDs.
    24142415 */
    2415 function wp_get_users_with_no_role() {
     2416function wp_get_users_with_no_role( $site_id = null ) {
    24162417        global $wpdb;
    24172418
    2418         if ( is_multisite() ) {
    2419                 return array();
     2419        if ( ! $site_id ) {
     2420                $site_id = get_current_blog_id();
    24202421        }
    24212422
    2422         $prefix = $wpdb->get_blog_prefix();
     2423        $prefix = $wpdb->get_blog_prefix( $site_id );
    24232424        $regex  = implode( '|', wp_roles()->get_names() );
    24242425        $regex  = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex );
    24252426        $users  = $wpdb->get_col( $wpdb->prepare( "