Make WordPress Core


Ignore:
Timestamp:
10/19/2025 05:18:55 PM (3 months ago)
Author:
johnjamesjacoby
Message:

Networks and Sites: prevent a PHP error in wp-admin/network/site-users.php.

This change brings the multisite specific promote user action up-to-speed with the single-site one, by adding:

  • capability checks where appropriate
  • a none check on $role to set it to an empty string

It also updates the inline documentation of the single-site promote user action in users.php, to match the suggested additions to the multisite file.

Props ignatiusjeroe, jeremyfelt, johnjamesjacoby, pratiklondhe, shanemuir, sudipatel007, techpartho.

Fixes #61100.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/users.php

    r59789 r60976  
    123123        $role           = $_REQUEST['new_role'];
    124124
    125         // Mocking the `none` role so we are able to save it to the database
     125        // Mock `none` as editable role.
    126126        $editable_roles['none'] = array(
    127127            'name' => __( '— No role for this site —' ),
     
    163163
    164164            $user = get_userdata( $id );
     165
     166            // If $role is empty, none will be set.
    165167            $user->set_role( $role );
    166168        }
Note: See TracChangeset for help on using the changeset viewer.