Issues (2010)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

wp-admin/user-new.php (10 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * New User Administration Screen.
4
 *
5
 * @package WordPress
6
 * @subpackage Administration
7
 */
8
9
/** WordPress Administration Bootstrap */
10
require_once( dirname( __FILE__ ) . '/admin.php' );
11
12
if ( is_multisite() ) {
13
	if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) {
14
		wp_die(
15
			'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
16
			'<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
17
			403
18
		);
19
	}
20
} elseif ( ! current_user_can( 'create_users' ) ) {
21
	wp_die(
22
		'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
23
		'<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
24
		403
25
	);
26
}
27
28
if ( is_multisite() ) {
29
	add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
30
}
31
32
if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
33
	check_admin_referer( 'add-user', '_wpnonce_add-user' );
34
35
	$user_details = null;
36
	$user_email = wp_unslash( $_REQUEST['email'] );
37
	if ( false !== strpos( $user_email, '@' ) ) {
38
		$user_details = get_user_by( 'email', $user_email );
0 ignored issues
show
It seems like $user_email defined by wp_unslash($_REQUEST['email']) on line 36 can also be of type array; however, get_user_by() does only seem to accept integer|string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
39
	} else {
40
		if ( is_super_admin() ) {
41
			$user_details = get_user_by( 'login', $user_email );
0 ignored issues
show
It seems like $user_email defined by wp_unslash($_REQUEST['email']) on line 36 can also be of type array; however, get_user_by() does only seem to accept integer|string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
42
		} else {
43
			wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
44
			die();
45
		}
46
	}
47
48
	if ( !$user_details ) {
49
		wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) );
50
		die();
51
	}
52
53
	if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
54
		wp_die(
55
			'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
56
			'<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
57
			403
58
		);
59
	}
60
61
	// Adding an existing user to this blog
62
	$new_user_email = $user_details->user_email;
63
	$redirect = 'user-new.php';
64
	$username = $user_details->user_login;
65
	$user_id = $user_details->ID;
66
	if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) {
67
		$redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' );
68
	} else {
69
		if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) {
70
			add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) );
71
			$redirect = add_query_arg( array( 'update' => 'addnoconfirmation' , 'user_id' => $user_id ), 'user-new.php' );
72
		} else {
73
			$newuser_key = substr( md5( $user_id ), 0, 5 );
74
			add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) );
75
76
			$roles = get_editable_roles();
77
			$role = $roles[ $_REQUEST['role'] ];
78
79
			/**
80
			 * Fires immediately after a user is invited to join a site, but before the notification is sent.
81
			 *
82
			 * @since 4.4.0
83
			 *
84
			 * @param int    $user_id     The invited user's ID.
85
			 * @param array  $role        The role of invited user.
86
			 * @param string $newuser_key The key of the invitation.
87
			 */
88
			do_action( 'invite_user', $user_id, $role, $newuser_key );
89
90
			/* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */
91
			$message = __( 'Hi,
92
93
You\'ve been invited to join \'%1$s\' at
94
%2$s with the role of %3$s.
95
96
Please click the following link to confirm the invite:
97
%4$s' );
98
			wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ), home_url( "/newbloguser/$newuser_key/" ) ) );
99
			$redirect = add_query_arg( array('update' => 'add'), 'user-new.php' );
100
		}
101
	}
102
	wp_redirect( $redirect );
103
	die();
104
} elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) {
105
	check_admin_referer( 'create-user', '_wpnonce_create-user' );
106
107 View Code Duplication
	if ( ! current_user_can( 'create_users' ) ) {
108
		wp_die(
109
			'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
110
			'<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
111
			403
112
		);
113
	}
114
115
	if ( ! is_multisite() ) {
116
		$user_id = edit_user();
117
118
		if ( is_wp_error( $user_id ) ) {
119
			$add_user_errors = $user_id;
120
		} else {
121
			if ( current_user_can( 'list_users' ) )
122
				$redirect = 'users.php?update=add&id=' . $user_id;
123
			else
124
				$redirect = add_query_arg( 'update', 'add', 'user-new.php' );
125
			wp_redirect( $redirect );
126
			die();
127
		}
128
	} else {
129
		// Adding a new user to this site
130
		$new_user_email = wp_unslash( $_REQUEST['email'] );
131
		$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
0 ignored issues
show
It seems like $new_user_email defined by wp_unslash($_REQUEST['email']) on line 130 can also be of type array; however, wpmu_validate_user_signup() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
132
		if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) {
133
			$add_user_errors = $user_details[ 'errors' ];
134
		} else {
135
			/**
136
			 * Filters the user_login, also known as the username, before it is added to the site.
137
			 *
138
			 * @since 2.0.3
139
			 *
140
			 * @param string $user_login The sanitized username.
141
			 */
142
			$new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
0 ignored issues
show
It seems like wp_unslash($_REQUEST['user_login']) targeting wp_unslash() can also be of type array; however, sanitize_user() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
143
			if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) {
144
				add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
145
				add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
146
			}
147
			wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) );
0 ignored issues
show
It seems like $new_user_email defined by wp_unslash($_REQUEST['email']) on line 130 can also be of type array; however, wpmu_signup_user() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
148
			if ( isset( $_POST[ 'noconfirmation' ] ) && current_user_can( 'manage_network_users' ) ) {
149
				$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
150
				$new_user = wpmu_activate_signup( $key );
151
				if ( is_wp_error( $new_user ) ) {
152
					$redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' );
153
				} else {
154
					$redirect = add_query_arg( array( 'update' => 'addnoconfirmation', 'user_id' => $new_user['user_id'] ), 'user-new.php' );
155
				}
156
			} else {
157
				$redirect = add_query_arg( array('update' => 'newuserconfirmation'), 'user-new.php' );
158
			}
159
			wp_redirect( $redirect );
160
			die();
161
		}
162
	}
163
}
164
165
$title = __('Add New User');
166
$parent_file = 'users.php';
167
168
$do_both = false;
169
if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') )
170
	$do_both = true;
171
172
$help = '<p>' . __('To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.') . '</p>';
173
174
if ( is_multisite() ) {
175
	$help .= '<p>' . __('Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user&#8217;s name to Edit the user profile under Network Admin > All Users.') . '</p>' .
176
	'<p>' . __('New users will receive an email letting them know they&#8217;ve been added as a user for your site. This email will also contain their password. Check the box if you don&#8217;t want the user to receive a welcome email.') . '</p>';
177
} else {
178
	$help .= '<p>' . __('New users are automatically assigned a password, which they can change after logging in. You can view or edit the assigned password by clicking the Show Password button. The username cannot be changed once the user has been added.') . '</p>' .
179
180
	'<p>' . __('By default, new users will receive an email letting them know they&#8217;ve been added as a user for your site. This email will also contain a password reset link. Uncheck the box if you don&#8217;t want to send the new user a welcome email.') . '</p>';
181
}
182
183
$help .= '<p>' . __('Remember to click the Add New User button at the bottom of this screen when you are finished.') . '</p>';
184
185
get_current_screen()->add_help_tab( array(
186
	'id'      => 'overview',
187
	'title'   => __('Overview'),
188
	'content' => $help,
189
) );
190
191
get_current_screen()->add_help_tab( array(
192
'id'      => 'user-roles',
193
'title'   => __('User Roles'),
194
'content' => '<p>' . __('Here is a basic overview of the different user roles and the permissions associated with each one:') . '</p>' .
195
				'<ul>' .
196
				'<li>' . __('Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.') . '</li>' .
197
				'<li>' . __('Contributors can write and manage their posts but not publish posts or upload media files.') . '</li>' .
198
				'<li>' . __('Authors can publish and manage their own posts, and are able to upload files.') . '</li>' .
199
				'<li>' . __('Editors can publish posts, manage posts as well as manage other people&#8217;s posts, etc.') . '</li>' .
200
				'<li>' . __('Administrators have access to all the administration features.') . '</li>' .
201
				'</ul>'
202
) );
203
204
get_current_screen()->set_help_sidebar(
205
    '<p><strong>' . __('For more information:') . '</strong></p>' .
206
    '<p>' . __('<a href="https://codex.wordpress.org/Users_Add_New_Screen" target="_blank">Documentation on Adding New Users</a>') . '</p>' .
207
    '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
208
);
209
210
wp_enqueue_script('wp-ajax-response');
211
wp_enqueue_script( 'user-profile' );
212
213
/**
214
 * Filters whether to enable user auto-complete for non-super admins in Multisite.
215
 *
216
 * @since 3.4.0
217
 *
218
 * @param bool $enable Whether to enable auto-complete for non-super admins. Default false.
219
 */
220
if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
221
	&& ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) )
222
) {
223
	wp_enqueue_script( 'user-suggest' );
224
}
225
226
require_once( ABSPATH . 'wp-admin/admin-header.php' );
227
228
if ( isset($_GET['update']) ) {
229
	$messages = array();
230
	if ( is_multisite() ) {
231
		$edit_link = '';
232 View Code Duplication
		if ( ( isset( $_GET['user_id'] ) ) ) {
233
			$user_id_new = absint( $_GET['user_id'] );
234
			if ( $user_id_new ) {
235
				$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
236
			}
237
		}
238
239
		switch ( $_GET['update'] ) {
240
			case "newuserconfirmation":
241
				$messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.');
242
				break;
243
			case "add":
244
				$messages[] = __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.');
245
				break;
246
			case "addnoconfirmation":
247 View Code Duplication
				if ( empty( $edit_link ) ) {
248
					$messages[] = __( 'User has been added to your site.' );
249
				} else {
250
					/* translators: %s: edit page url */
251
					$messages[] = sprintf( __( 'User has been added to your site. <a href="%s">Edit user</a>' ), $edit_link );
252
				}
253
				break;
254
			case "addexisting":
255
				$messages[] = __('That user is already a member of this site.');
256
				break;
257
			case "does_not_exist":
258
				$messages[] = __('The requested user does not exist.');
259
				break;
260
			case "enter_email":
261
				$messages[] = __('Please enter a valid email address.');
262
				break;
263
		}
264
	} else {
265
		if ( 'add' == $_GET['update'] )
266
			$messages[] = __('User added.');
267
	}
268
}
269
?>
270
<div class="wrap">
271
<h1 id="add-new-user"><?php
272
if ( current_user_can( 'create_users' ) ) {
273
	_e( 'Add New User' );
274
} elseif ( current_user_can( 'promote_users' ) ) {
275
	_e( 'Add Existing User' );
276
} ?>
277
</h1>
278
279 View Code Duplication
<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
280
	<div class="error">
281
		<ul>
282
		<?php
283
			foreach ( $errors->get_error_messages() as $err )
284
				echo "<li>$err</li>\n";
285
		?>
286
		</ul>
287
	</div>
288
<?php endif;
289
290
if ( ! empty( $messages ) ) {
291
	foreach ( $messages as $msg )
292
		echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
293
} ?>
294
295 View Code Duplication
<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
296
	<div class="error">
297
		<?php
298
			foreach ( $add_user_errors->get_error_messages() as $message )
299
				echo "<p>$message</p>";
300
		?>
301
	</div>
302
<?php endif; ?>
303
<div id="ajax-response"></div>
304
305
<?php
306
if ( is_multisite() ) {
307
	if ( $do_both )
308
		echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>';
309
	if ( !is_super_admin() ) {
310
		echo '<p>' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>';
311
		$label = __('Email');
312
		$type  = 'email';
313 View Code Duplication
	} else {
314
		echo '<p>' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '</p>';
315
		$label = __('Email or Username');
316
		$type  = 'text';
317
	}
318
?>
319
<form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"<?php
320
	/**
321
	 * Fires inside the adduser form tag.
322
	 *
323
	 * @since 3.0.0
324
	 */
325
	do_action( 'user_new_form_tag' );
326
?>>
327
<input name="action" type="hidden" value="adduser" />
328
<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
329
330
<table class="form-table">
331
	<tr class="form-field form-required">
332
		<th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
333
		<td><input name="email" type="<?php echo $type; ?>" id="adduser-email" class="wp-suggest-user" value="" /></td>
334
	</tr>
335
	<tr class="form-field">
336
		<th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th>
337
		<td><select name="role" id="adduser-role">
338
			<?php wp_dropdown_roles( get_option('default_role') ); ?>
339
			</select>
340
		</td>
341
	</tr>
342
<?php if ( current_user_can( 'manage_network_users' ) ) { ?>
343
	<tr>
344
		<th scope="row"><label for="adduser-noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
345
		<td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label></td>
346
	</tr>
347
<?php } ?>
348
</table>
349
<?php
350
/**
351
 * Fires at the end of the new user form.
352
 *
353
 * Passes a contextual string to make both types of new user forms
354
 * uniquely targetable. Contexts are 'add-existing-user' (Multisite),
355
 * and 'add-new-user' (single site and network admin).
356
 *
357
 * @since 3.7.0
358
 *
359
 * @param string $type A contextual string specifying which type of new user form the hook follows.
360
 */
361
do_action( 'user_new_form', 'add-existing-user' );
362
?>
363
<?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
364
</form>
365
<?php
366
} // is_multisite()
367
368
if ( current_user_can( 'create_users') ) {
369
	if ( $do_both )
370
		echo '<h2 id="create-new-user">' . __( 'Add New User' ) . '</h2>';
371
?>
372
<p><?php _e('Create a brand new user and add them to this site.'); ?></p>
373
<form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"<?php
374
	/** This action is documented in wp-admin/user-new.php */
375
	do_action( 'user_new_form_tag' );
376
?>>
377
<input name="action" type="hidden" value="createuser" />
378
<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
379
<?php
380
// Load up the passed data, else set to a default.
381
$creating = isset( $_POST['createuser'] );
382
383
$new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
384
$new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
385
$new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
386
$new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
387
$new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
388
$new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
389
$new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true;
390
$new_user_ignore_pass = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : '';
391
392
?>
393
<table class="form-table">
394
	<tr class="form-field form-required">
395
		<th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
396
		<td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" /></td>
0 ignored issues
show
It seems like $new_user_login defined by $creating && isset($_POS...OST['user_login']) : '' on line 383 can also be of type array; however, esc_attr() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
397
	</tr>
398
	<tr class="form-field form-required">
399
		<th scope="row"><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
400
		<td><input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" /></td>
0 ignored issues
show
It seems like $new_user_email defined by $creating && isset($_POS...h($_POST['email']) : '' on line 386 can also be of type array; however, esc_attr() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
401
	</tr>
402
<?php if ( !is_multisite() ) { ?>
403
	<tr class="form-field">
404
		<th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
405
		<td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr($new_user_firstname); ?>" /></td>
0 ignored issues
show
It seems like $new_user_firstname defined by $creating && isset($_POS...OST['first_name']) : '' on line 384 can also be of type array; however, esc_attr() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
406
	</tr>
407
	<tr class="form-field">
408
		<th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
409
		<td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr($new_user_lastname); ?>" /></td>
0 ignored issues
show
It seems like $new_user_lastname defined by $creating && isset($_POS...POST['last_name']) : '' on line 385 can also be of type array; however, esc_attr() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
410
	</tr>
411
	<tr class="form-field">
412
		<th scope="row"><label for="url"><?php _e('Website') ?></label></th>
413
		<td><input name="url" type="url" id="url" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" /></td>
0 ignored issues
show
It seems like $new_user_uri defined by $creating && isset($_POS...ash($_POST['url']) : '' on line 387 can also be of type array; however, esc_attr() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
414
	</tr>
415
	<tr class="form-field form-required user-pass1-wrap">
416
		<th scope="row">
417
			<label for="pass1">
418
				<?php _e( 'Password' ); ?>
419
				<span class="description hide-if-js"><?php _e( '(required)' ); ?></span>
420
			</label>
421
		</th>
422
		<td>
423
			<input class="hidden" value=" " /><!-- #24364 workaround -->
424
			<button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button>
425
			<div class="wp-pwd hide-if-js">
426
				<?php $initial_password = wp_generate_password( 24 ); ?>
427
				<span class="password-input-wrapper">
428
					<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
429
				</span>
430
				<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
431
					<span class="dashicons dashicons-hidden"></span>
432
					<span class="text"><?php _e( 'Hide' ); ?></span>
433
				</button>
434
				<button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
435
					<span class="text"><?php _e( 'Cancel' ); ?></span>
436
				</button>
437
				<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
438
			</div>
439
		</td>
440
	</tr>
441
	<tr class="form-field form-required user-pass2-wrap hide-if-js">
442
		<th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
443
		<td>
444
		<input name="pass2" type="password" id="pass2" autocomplete="off" />
445
		</td>
446
	</tr>
447
	<tr class="pw-weak">
448
		<th><?php _e( 'Confirm Password' ); ?></th>
449
		<td>
450
			<label>
451
				<input type="checkbox" name="pw_weak" class="pw-checkbox" />
452
				<?php _e( 'Confirm use of weak password' ); ?>
453
			</label>
454
		</td>
455
	</tr>
456
	<tr>
457
		<th scope="row"><?php _e( 'Send User Notification' ) ?></th>
458
		<td><label for="send_user_notification"><input type="checkbox" name="send_user_notification" id="send_user_notification" value="1" <?php checked( $new_user_send_notification ); ?> /> <?php _e( 'Send the new user an email about their account.' ); ?></label></td>
459
	</tr>
460
<?php } // !is_multisite ?>
461
	<tr class="form-field">
462
		<th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
463
		<td><select name="role" id="role">
464
			<?php
465
			if ( !$new_user_role )
466
				$new_user_role = !empty($current_role) ? $current_role : get_option('default_role');
467
			wp_dropdown_roles($new_user_role);
468
			?>
469
			</select>
470
		</td>
471
	</tr>
472
	<?php if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { ?>
473
	<tr>
474
		<th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
475
		<td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1" <?php checked( $new_user_ignore_pass ); ?> /> <?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label></td>
476
	</tr>
477
	<?php } ?>
478
</table>
479
480
<?php
481
/** This action is documented in wp-admin/user-new.php */
482
do_action( 'user_new_form', 'add-new-user' );
483
?>
484
485
<?php submit_button( __( 'Add New User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?>
486
487
</form>
488
<?php } // current_user_can('create_users') ?>
489
</div>
490
<?php
491
include( ABSPATH . 'wp-admin/admin-footer.php' );
492