site_id != $wpdb->siteid ) wp_die( __( 'You do not have permission to access this page.' ) ); $is_main_site = is_main_site( $id ); if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { check_admin_referer( 'edit-site' ); switch_to_blog( $id ); // get blog prefix $blog_prefix = $wpdb->get_blog_prefix( $id ); // user roles if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) { $newroles = $_POST['role']; reset( $newroles ); foreach ( (array) $newroles as $userid => $role ) { $user = new WP_User( $userid ); if ( empty( $user->ID ) ) continue; $user->for_blog( $id ); $user->set_role( $role ); } } // remove user if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) { reset( $_POST['blogusers'] ); foreach ( (array) $_POST['blogusers'] as $key => $val ) remove_user_from_blog( $key, $id ); } // change password if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) { reset( $_POST['user_password'] ); $newroles = $_POST['role']; foreach ( (array) $_POST['user_password'] as $userid => $pass ) { unset( $_POST['role'] ); $_POST['role'] = $newroles[ $userid ]; if ( $pass != '' ) { $cap = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); $userdata = get_userdata($userid); $_POST['pass1'] = $_POST['pass2'] = $pass; $_POST['email'] = $userdata->user_email; $_POST['rich_editing'] = $userdata->rich_editing; edit_user( $userid ); if ( $cap == null ) $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); } } unset( $_POST['role'] ); $_POST['role'] = $newroles; } // add user if ( !empty( $_POST['newuser'] ) ) { $newuser = $_POST['newuser']; $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); if ( $userid ) { $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); if ( $user == false ) add_user_to_blog( $id, $userid, $_POST['new_role'] ); } } restore_current_blog(); wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-users.php') ); } if ( isset($_GET['update']) ) { $messages = array(); if ( 'updated' == $_GET['update'] ) $messages[] = __('Site users updated.'); } $title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id)); $parent_file = 'sites.php'; $submenu_file = 'sites.php'; require('../admin-header.php'); ?>
' . $msg . '