Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve issue with changing user role to 'None' in multisite at wp-admin/network/site-users.php?id=xxx #6470

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: resolve issue with changing user role to 'None' in multisite at …
…wp-admin/network/site-users.php?id=xxx
  • Loading branch information
mi5t4n committed May 1, 2024
commit 5a8acf3213cb28c5a0018a2a2bcc24ab9eecb24d
16 changes: 15 additions & 1 deletion src/wp-admin/network/site-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,27 @@

case 'promote':
check_admin_referer( 'bulk-users' );

if ( ! current_user_can( 'promote_users' ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
}

$editable_roles = get_editable_roles();
$role = $_REQUEST['new_role'];

if ( empty( $editable_roles[ $role ] ) ) {
// Mocking the `none` role so we are able to save it to the database
$editable_roles['none'] = array(
'name' => __( '— No role for this site —' ),
);

if ( ! $role || empty( $editable_roles[ $role ] ) ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
}

if ( 'none' === $role ) {
$role = '';
}

if ( isset( $_REQUEST['users'] ) ) {
$userids = $_REQUEST['users'];
$update = 'promote';
Expand Down
Loading