Make WordPress Core

Changeset 50228 for trunk


Ignore:
Timestamp:
02/05/2021 02:38:15 PM (4 years ago)
Author:
johnbillion
Message:

Users: Allow the role of users to be bulk changed to no role from the Users listing screen.

This option is already available when editing an individual user, but it was previously missing from the bulk actions.

Props bonniebeeman, sabernhardt, ovidiul, jeroenrotty

Fixes #52238

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r50129 r50228  
    301301            <option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
    302302            <?php wp_dropdown_roles(); ?>
     303            <option value="none"><?php echo __( '&mdash; No role for this site &mdash;' ) ?> </option>
    303304        </select>
    304305            <?php
  • trunk/src/wp-admin/users.php

    r50139 r50228  
    115115        $role           = $_REQUEST['new_role'];
    116116
     117        // Mocking the `none` role so we are able to save it to the database
     118        $editable_roles['none'] = array(
     119            'name' => __( '&mdash; No role for this site &mdash;' ),
     120        );
     121
    117122        if ( ! $role || empty( $editable_roles[ $role ] ) ) {
    118123            wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
     124        }
     125
     126        if ( 'none' === $role ) {
     127            $role = '';
    119128        }
    120129
Note: See TracChangeset for help on using the changeset viewer.