diff --git a/bulk-user-management.php b/bulk-user-management.php index 27d4853..048307a 100644 --- a/bulk-user-management.php +++ b/bulk-user-management.php @@ -297,6 +297,10 @@ public function handle_promote_users_form() { public function promote_users($blogids = array(), $userids = array(), $role) { foreach ( $userids as $id ) { foreach ( $blogids as $blogid ) { + // Is the current user already a member of the blog with the given `$role`? If so, continue. + if ( count ( get_users( array( 'blog_id' => $blogid, 'role' => $role, 'include' => array ( $id ) ) ) ) > 0 ) { + continue; + } add_user_to_blog( $blogid, $id, $role ); } } @@ -358,6 +362,10 @@ public function handle_remove_users_form() { public function remove_users($blogids = array(), $userids = array()) { foreach ( $userids as $userid ) { foreach ( $blogids as $blogid ) { + // Is the current user already not a member of the blog? If so, continue. + if ( count ( get_users( array( 'blog_id' => $blogid, 'include' => array ( $userid ) ) ) ) == 0 ) { + continue; + } remove_user_from_blog( $userid, $blogid ); } } diff --git a/includes/class-bulk-user-table.php b/includes/class-bulk-user-table.php index e92f9d0..cbc38b2 100644 --- a/includes/class-bulk-user-table.php +++ b/includes/class-bulk-user-table.php @@ -223,7 +223,10 @@ function inline_edit() {