WordPress.org

Make WordPress Core

Ticket #47593: 47593.diff

File 47593.diff, 1.2 KB (added by deepaklalwani, 3 months ago)
  • src/wp-admin/includes/class-wp-users-list-table.php

    diff --git src/wp-admin/includes/class-wp-users-list-table.php src/wp-admin/includes/class-wp-users-list-table.php
    index 018654bdd2..107fb308ed 100644
    class WP_Users_List_Table extends WP_List_Table { 
    295295                <select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
    296296                        <option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
    297297                        <?php wp_dropdown_roles(); ?>
     298                        <option value="none"><?php esc_html_e( '&mdash; No role for this site &mdash;' ); ?></option>
    298299                </select>
    299300                        <?php
    300301                        submit_button( __( 'Change' ), '', $button_id, false );
  • src/wp-admin/users.php

    diff --git src/wp-admin/users.php src/wp-admin/users.php
    index 3742e95276..ed2756fcd2 100644
    switch ( $wp_list_table->current_action() ) { 
    119119                        $role = $_REQUEST['new_role'];
    120120                }
    121121
    122                 if ( ! $role || empty( $editable_roles[ $role ] ) ) {
     122                // Set role to empty string if no role option is selected.
     123                if ( 'none' === $role ) {
     124                        $role = '';
     125                }
     126
     127                if ( ! empty( $role ) && empty( $editable_roles[ $role ] ) ) {
    123128                        wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
    124129                }
    125130