author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Edit Site Users Administration Screen |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Multisite |
|
7 |
* @since 3.1.0 |
|
8 |
*/ |
|
9 |
||
10 |
/** Load WordPress Administration Bootstrap */ |
|
11 |
require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
12 |
||
13 |
if ( ! current_user_can('manage_sites') ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
wp_die( __( 'Sorry, you are not allowed to edit this site.' ), 403 ); |
0 | 15 |
|
16 |
$wp_list_table = _get_list_table('WP_Users_List_Table'); |
|
17 |
$wp_list_table->prepare_items(); |
|
18 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
get_current_screen()->set_screen_reader_content( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
'heading_views' => __( 'Filter site users list' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
'heading_pagination' => __( 'Site users list navigation' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
'heading_list' => __( 'Site users list' ), |
0 | 26 |
) ); |
27 |
||
28 |
$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] ); |
|
29 |
$referer = remove_query_arg( 'update', wp_get_referer() ); |
|
30 |
||
5 | 31 |
if ( ! empty( $_REQUEST['paged'] ) ) { |
32 |
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer ); |
|
33 |
} |
|
34 |
||
0 | 35 |
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
36 |
||
37 |
if ( ! $id ) |
|
38 |
wp_die( __('Invalid site ID.') ); |
|
39 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
$details = get_site( $id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
if ( ! $details ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
wp_die( __( 'The requested site does not exist.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
|
0 | 45 |
if ( ! can_edit_network( $details->site_id ) ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
0 | 47 |
|
48 |
$is_main_site = is_main_site( $id ); |
|
49 |
||
50 |
switch_to_blog( $id ); |
|
51 |
||
52 |
$action = $wp_list_table->current_action(); |
|
53 |
||
54 |
if ( $action ) { |
|
55 |
||
56 |
switch ( $action ) { |
|
57 |
case 'newuser': |
|
58 |
check_admin_referer( 'add-user', '_wpnonce_add-new-user' ); |
|
59 |
$user = $_POST['user']; |
|
60 |
if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) { |
|
61 |
$update = 'err_new'; |
|
62 |
} else { |
|
63 |
$password = wp_generate_password( 12, false); |
|
64 |
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); |
|
65 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
if ( false === $user_id ) { |
0 | 67 |
$update = 'err_new_dup'; |
68 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
$result = add_user_to_blog( $id, $user_id, $_POST['new_role'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
if ( is_wp_error( $result ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
$update = 'err_add_fail'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
$update = 'newuser'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
* Fires after a user has been created via the network site-users.php page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
* @param int $user_id ID of the newly created user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
do_action( 'network_site_users_created_user', $user_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
} |
0 | 84 |
} |
85 |
} |
|
86 |
break; |
|
87 |
||
88 |
case 'adduser': |
|
89 |
check_admin_referer( 'add-user', '_wpnonce_add-user' ); |
|
90 |
if ( !empty( $_POST['newuser'] ) ) { |
|
91 |
$update = 'adduser'; |
|
92 |
$newuser = $_POST['newuser']; |
|
93 |
$user = get_user_by( 'login', $newuser ); |
|
94 |
if ( $user && $user->exists() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
if ( ! is_user_member_of_blog( $user->ID, $id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
$result = add_user_to_blog( $id, $user->ID, $_POST['new_role'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
if ( is_wp_error( $result ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
$update = 'err_add_fail'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
} else { |
0 | 102 |
$update = 'err_add_member'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
} |
0 | 104 |
} else { |
105 |
$update = 'err_add_notfound'; |
|
106 |
} |
|
107 |
} else { |
|
108 |
$update = 'err_add_notfound'; |
|
109 |
} |
|
110 |
break; |
|
111 |
||
112 |
case 'remove': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
if ( ! current_user_can( 'remove_users' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
|
0 | 117 |
check_admin_referer( 'bulk-users' ); |
118 |
||
119 |
$update = 'remove'; |
|
120 |
if ( isset( $_REQUEST['users'] ) ) { |
|
121 |
$userids = $_REQUEST['users']; |
|
122 |
||
123 |
foreach ( $userids as $user_id ) { |
|
124 |
$user_id = (int) $user_id; |
|
125 |
remove_user_from_blog( $user_id, $id ); |
|
126 |
} |
|
127 |
} elseif ( isset( $_GET['user'] ) ) { |
|
128 |
remove_user_from_blog( $_GET['user'] ); |
|
129 |
} else { |
|
130 |
$update = 'err_remove'; |
|
131 |
} |
|
132 |
break; |
|
133 |
||
134 |
case 'promote': |
|
135 |
check_admin_referer( 'bulk-users' ); |
|
136 |
$editable_roles = get_editable_roles(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
$role = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
if ( ! empty( $_REQUEST['new_role2'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
$role = $_REQUEST['new_role2']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
} elseif ( ! empty( $_REQUEST['new_role'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
$role = $_REQUEST['new_role']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
if ( empty( $editable_roles[ $role ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
} |
0 | 147 |
|
148 |
if ( isset( $_REQUEST['users'] ) ) { |
|
149 |
$userids = $_REQUEST['users']; |
|
150 |
$update = 'promote'; |
|
151 |
foreach ( $userids as $user_id ) { |
|
152 |
$user_id = (int) $user_id; |
|
153 |
||
154 |
// If the user doesn't already belong to the blog, bail. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
if ( ! is_user_member_of_blog( $user_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
'<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
'<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
403 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
} |
0 | 162 |
|
163 |
$user = get_userdata( $user_id ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
$user->set_role( $role ); |
0 | 165 |
} |
166 |
} else { |
|
167 |
$update = 'err_promote'; |
|
168 |
} |
|
169 |
break; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
if ( ! isset( $_REQUEST['users'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
check_admin_referer( 'bulk-users' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
$userids = $_REQUEST['users']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
/** This action is documented in wp-admin/network/site-themes.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
$referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
$update = $action; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
break; |
0 | 180 |
} |
181 |
||
182 |
wp_safe_redirect( add_query_arg( 'update', $update, $referer ) ); |
|
183 |
exit(); |
|
184 |
} |
|
185 |
||
186 |
restore_current_blog(); |
|
187 |
||
188 |
if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) { |
|
189 |
wp_safe_redirect( $referer ); |
|
190 |
exit(); |
|
191 |
} |
|
192 |
||
5 | 193 |
add_screen_option( 'per_page' ); |
0 | 194 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
/* translators: %s: site name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); |
0 | 197 |
|
198 |
$parent_file = 'sites.php'; |
|
199 |
$submenu_file = 'sites.php'; |
|
200 |
||
5 | 201 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
* Filters whether to show the Add Existing User form on the Multisite Users screen. |
5 | 203 |
* |
204 |
* @since 3.1.0 |
|
205 |
* |
|
206 |
* @param bool $bool Whether to show the Add Existing User form. Default true. |
|
207 |
*/ |
|
0 | 208 |
if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) |
209 |
wp_enqueue_script( 'user-suggest' ); |
|
210 |
||
211 |
require( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
|
212 |
||
5 | 213 |
<script type="text/javascript"> |
0 | 214 |
var current_site_id = <?php echo $id; ?>; |
215 |
</script> |
|
216 |
||
217 |
||
218 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
<h1 id="edit-site"><?php echo $title; ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
<p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p> |
0 | 221 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
network_edit_site_nav( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
'blog_id' => $id, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
'selected' => 'site-users' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
) ); |
0 | 227 |
|
228 |
if ( isset($_GET['update']) ) : |
|
229 |
switch($_GET['update']) { |
|
230 |
case 'adduser': |
|
5 | 231 |
echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User added.' ) . '</p></div>'; |
0 | 232 |
break; |
233 |
case 'err_add_member': |
|
5 | 234 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'User is already a member of this site.' ) . '</p></div>'; |
0 | 235 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
case 'err_add_fail': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'User could not be added to this site.' ) . '</p></div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
break; |
0 | 239 |
case 'err_add_notfound': |
5 | 240 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>'; |
0 | 241 |
break; |
242 |
case 'promote': |
|
5 | 243 |
echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>'; |
0 | 244 |
break; |
245 |
case 'err_promote': |
|
5 | 246 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Select a user to change role.' ) . '</p></div>'; |
0 | 247 |
break; |
248 |
case 'remove': |
|
5 | 249 |
echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User removed from this site.' ) . '</p></div>'; |
0 | 250 |
break; |
251 |
case 'err_remove': |
|
5 | 252 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Select a user to remove.' ) . '</p></div>'; |
0 | 253 |
break; |
254 |
case 'newuser': |
|
5 | 255 |
echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User created.' ) . '</p></div>'; |
0 | 256 |
break; |
257 |
case 'err_new': |
|
5 | 258 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Enter the username and email.' ) . '</p></div>'; |
0 | 259 |
break; |
260 |
case 'err_new_dup': |
|
5 | 261 |
echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Duplicated username or email address.' ) . '</p></div>'; |
0 | 262 |
break; |
263 |
} |
|
264 |
endif; ?> |
|
265 |
||
5 | 266 |
<form class="search-form" method="get"> |
0 | 267 |
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?> |
268 |
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
|
269 |
</form> |
|
270 |
||
271 |
<?php $wp_list_table->views(); ?> |
|
272 |
||
273 |
<form method="post" action="site-users.php?action=update-site"> |
|
274 |
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
|
275 |
||
276 |
<?php $wp_list_table->display(); ?> |
|
277 |
||
278 |
</form> |
|
279 |
||
5 | 280 |
<?php |
281 |
/** |
|
282 |
* Fires after the list table on the Users screen in the Multisite Network Admin. |
|
283 |
* |
|
284 |
* @since 3.1.0 |
|
285 |
*/ |
|
286 |
do_action( 'network_site_users_after_list_table' ); |
|
0 | 287 |
|
5 | 288 |
/** This filter is documented in wp-admin/network/site-users.php */ |
289 |
if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) : ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
<h2 id="add-existing-user"><?php _e( 'Add Existing User' ); ?></h2> |
0 | 291 |
<form action="site-users.php?action=adduser" id="adduser" method="post"> |
292 |
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
|
293 |
<table class="form-table"> |
|
294 |
<tr> |
|
5 | 295 |
<th scope="row"><label for="newuser"><?php _e( 'Username' ); ?></label></th> |
0 | 296 |
<td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td> |
297 |
</tr> |
|
298 |
<tr> |
|
5 | 299 |
<th scope="row"><label for="new_role_adduser"><?php _e( 'Role' ); ?></label></th> |
300 |
<td><select name="new_role" id="new_role_adduser"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
switch_to_blog( $id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
wp_dropdown_roles( get_option( 'default_role' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
?> |
0 | 306 |
</select></td> |
307 |
</tr> |
|
308 |
</table> |
|
309 |
<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?> |
|
310 |
<?php submit_button( __( 'Add User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-existing-user' ) ); ?> |
|
311 |
</form> |
|
312 |
<?php endif; ?> |
|
313 |
||
5 | 314 |
<?php |
315 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* Filters whether to show the Add New User form on the Multisite Users screen. |
5 | 317 |
* |
318 |
* @since 3.1.0 |
|
319 |
* |
|
320 |
* @param bool $bool Whether to show the Add New User form. Default true. |
|
321 |
*/ |
|
322 |
if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
<h2 id="add-new-user"><?php _e( 'Add New User' ); ?></h2> |
0 | 324 |
<form action="<?php echo network_admin_url('site-users.php?action=newuser'); ?>" id="newuser" method="post"> |
325 |
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
|
326 |
<table class="form-table"> |
|
327 |
<tr> |
|
5 | 328 |
<th scope="row"><label for="user_username"><?php _e( 'Username' ) ?></label></th> |
329 |
<td><input type="text" class="regular-text" name="user[username]" id="user_username" /></td> |
|
0 | 330 |
</tr> |
331 |
<tr> |
|
5 | 332 |
<th scope="row"><label for="user_email"><?php _e( 'Email' ) ?></label></th> |
333 |
<td><input type="text" class="regular-text" name="user[email]" id="user_email" /></td> |
|
334 |
</tr> |
|
335 |
<tr> |
|
336 |
<th scope="row"><label for="new_role_newuser"><?php _e( 'Role' ); ?></label></th> |
|
337 |
<td><select name="new_role" id="new_role_newuser"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
switch_to_blog( $id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
wp_dropdown_roles( get_option( 'default_role' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
restore_current_blog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
?> |
0 | 343 |
</select></td> |
344 |
</tr> |
|
345 |
<tr class="form-field"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
<td colspan="2"><?php _e( 'A password reset link will be sent to the user via email.' ) ?></td> |
0 | 347 |
</tr> |
348 |
</table> |
|
349 |
<?php wp_nonce_field( 'add-user', '_wpnonce_add-new-user' ) ?> |
|
350 |
<?php submit_button( __( 'Add New User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-user' ) ); ?> |
|
351 |
</form> |
|
352 |
<?php endif; ?> |
|
353 |
</div> |
|
354 |
<?php |
|
355 |
require( ABSPATH . 'wp-admin/admin-footer.php' ); |