Edit File by line
/home/barbar84/public_h.../wp-admin
File: user-new.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* New User Administration Screen.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/** WordPress Administration Bootstrap */
[8] Fix | Delete
require_once __DIR__ . '/admin.php';
[9] Fix | Delete
[10] Fix | Delete
if ( is_multisite() ) {
[11] Fix | Delete
if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) ) {
[12] Fix | Delete
wp_die(
[13] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[14] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
[15] Fix | Delete
403
[16] Fix | Delete
);
[17] Fix | Delete
}
[18] Fix | Delete
} elseif ( ! current_user_can( 'create_users' ) ) {
[19] Fix | Delete
wp_die(
[20] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[21] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
[22] Fix | Delete
403
[23] Fix | Delete
);
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
if ( is_multisite() ) {
[27] Fix | Delete
add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
[31] Fix | Delete
check_admin_referer( 'add-user', '_wpnonce_add-user' );
[32] Fix | Delete
[33] Fix | Delete
$user_details = null;
[34] Fix | Delete
$user_email = wp_unslash( $_REQUEST['email'] );
[35] Fix | Delete
if ( false !== strpos( $user_email, '@' ) ) {
[36] Fix | Delete
$user_details = get_user_by( 'email', $user_email );
[37] Fix | Delete
} else {
[38] Fix | Delete
if ( current_user_can( 'manage_network_users' ) ) {
[39] Fix | Delete
$user_details = get_user_by( 'login', $user_email );
[40] Fix | Delete
} else {
[41] Fix | Delete
wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) );
[42] Fix | Delete
die();
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
if ( ! $user_details ) {
[47] Fix | Delete
wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) );
[48] Fix | Delete
die();
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
[52] Fix | Delete
wp_die(
[53] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[54] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to add users to this network.' ) . '</p>',
[55] Fix | Delete
403
[56] Fix | Delete
);
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
// Adding an existing user to this blog.
[60] Fix | Delete
$new_user_email = array();
[61] Fix | Delete
$redirect = 'user-new.php';
[62] Fix | Delete
$username = $user_details->user_login;
[63] Fix | Delete
$user_id = $user_details->ID;
[64] Fix | Delete
if ( null != $username && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
[65] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' );
[66] Fix | Delete
} else {
[67] Fix | Delete
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
[68] Fix | Delete
$result = add_existing_user_to_blog(
[69] Fix | Delete
array(
[70] Fix | Delete
'user_id' => $user_id,
[71] Fix | Delete
'role' => $_REQUEST['role'],
[72] Fix | Delete
)
[73] Fix | Delete
);
[74] Fix | Delete
[75] Fix | Delete
if ( ! is_wp_error( $result ) ) {
[76] Fix | Delete
$redirect = add_query_arg(
[77] Fix | Delete
array(
[78] Fix | Delete
'update' => 'addnoconfirmation',
[79] Fix | Delete
'user_id' => $user_id,
[80] Fix | Delete
),
[81] Fix | Delete
'user-new.php'
[82] Fix | Delete
);
[83] Fix | Delete
} else {
[84] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' );
[85] Fix | Delete
}
[86] Fix | Delete
} else {
[87] Fix | Delete
$newuser_key = wp_generate_password( 20, false );
[88] Fix | Delete
add_option(
[89] Fix | Delete
'new_user_' . $newuser_key,
[90] Fix | Delete
array(
[91] Fix | Delete
'user_id' => $user_id,
[92] Fix | Delete
'email' => $user_details->user_email,
[93] Fix | Delete
'role' => $_REQUEST['role'],
[94] Fix | Delete
)
[95] Fix | Delete
);
[96] Fix | Delete
[97] Fix | Delete
$roles = get_editable_roles();
[98] Fix | Delete
$role = $roles[ $_REQUEST['role'] ];
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Fires immediately after an existing user is invited to join the site, but before the notification is sent.
[102] Fix | Delete
*
[103] Fix | Delete
* @since 4.4.0
[104] Fix | Delete
*
[105] Fix | Delete
* @param int $user_id The invited user's ID.
[106] Fix | Delete
* @param array $role Array containing role information for the invited user.
[107] Fix | Delete
* @param string $newuser_key The key of the invitation.
[108] Fix | Delete
*/
[109] Fix | Delete
do_action( 'invite_user', $user_id, $role, $newuser_key );
[110] Fix | Delete
[111] Fix | Delete
$switched_locale = switch_to_locale( get_user_locale( $user_details ) );
[112] Fix | Delete
[113] Fix | Delete
/* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
[114] Fix | Delete
$message = __(
[115] Fix | Delete
'Hi,
[116] Fix | Delete
[117] Fix | Delete
You\'ve been invited to join \'%1$s\' at
[118] Fix | Delete
%2$s with the role of %3$s.
[119] Fix | Delete
[120] Fix | Delete
Please click the following link to confirm the invite:
[121] Fix | Delete
%4$s'
[122] Fix | Delete
);
[123] Fix | Delete
[124] Fix | Delete
$new_user_email['to'] = $user_details->user_email;
[125] Fix | Delete
$new_user_email['subject'] = sprintf(
[126] Fix | Delete
/* translators: Joining confirmation notification email subject. %s: Site title. */
[127] Fix | Delete
__( '[%s] Joining Confirmation' ),
[128] Fix | Delete
wp_specialchars_decode( get_option( 'blogname' ) )
[129] Fix | Delete
);
[130] Fix | Delete
$new_user_email['message'] = sprintf(
[131] Fix | Delete
$message,
[132] Fix | Delete
get_option( 'blogname' ),
[133] Fix | Delete
home_url(),
[134] Fix | Delete
wp_specialchars_decode( translate_user_role( $role['name'] ) ),
[135] Fix | Delete
home_url( "/newbloguser/$newuser_key/" )
[136] Fix | Delete
);
[137] Fix | Delete
$new_user_email['headers'] = '';
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Filters the contents of the email sent when an existing user is invited to join the site.
[141] Fix | Delete
*
[142] Fix | Delete
* @since 5.6.0
[143] Fix | Delete
*
[144] Fix | Delete
* @param array $new_user_email {
[145] Fix | Delete
* Used to build wp_mail().
[146] Fix | Delete
*
[147] Fix | Delete
* @type string $to The email address of the invited user.
[148] Fix | Delete
* @type string $subject The subject of the email.
[149] Fix | Delete
* @type string $message The content of the email.
[150] Fix | Delete
* @type string $headers Headers.
[151] Fix | Delete
* }
[152] Fix | Delete
* @param int $user_id The invited user's ID.
[153] Fix | Delete
* @param array $role Array containing role information for the invited user.
[154] Fix | Delete
* @param string $newuser_key The key of the invitation.
[155] Fix | Delete
*
[156] Fix | Delete
*/
[157] Fix | Delete
$new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key );
[158] Fix | Delete
[159] Fix | Delete
wp_mail(
[160] Fix | Delete
$new_user_email['to'],
[161] Fix | Delete
$new_user_email['subject'],
[162] Fix | Delete
$new_user_email['message'],
[163] Fix | Delete
$new_user_email['headers']
[164] Fix | Delete
);
[165] Fix | Delete
[166] Fix | Delete
if ( $switched_locale ) {
[167] Fix | Delete
restore_previous_locale();
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' );
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
wp_redirect( $redirect );
[174] Fix | Delete
die();
[175] Fix | Delete
} elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) {
[176] Fix | Delete
check_admin_referer( 'create-user', '_wpnonce_create-user' );
[177] Fix | Delete
[178] Fix | Delete
if ( ! current_user_can( 'create_users' ) ) {
[179] Fix | Delete
wp_die(
[180] Fix | Delete
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
[181] Fix | Delete
'<p>' . __( 'Sorry, you are not allowed to create users.' ) . '</p>',
[182] Fix | Delete
403
[183] Fix | Delete
);
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
if ( ! is_multisite() ) {
[187] Fix | Delete
$user_id = edit_user();
[188] Fix | Delete
[189] Fix | Delete
if ( is_wp_error( $user_id ) ) {
[190] Fix | Delete
$add_user_errors = $user_id;
[191] Fix | Delete
} else {
[192] Fix | Delete
if ( current_user_can( 'list_users' ) ) {
[193] Fix | Delete
$redirect = 'users.php?update=add&id=' . $user_id;
[194] Fix | Delete
} else {
[195] Fix | Delete
$redirect = add_query_arg( 'update', 'add', 'user-new.php' );
[196] Fix | Delete
}
[197] Fix | Delete
wp_redirect( $redirect );
[198] Fix | Delete
die();
[199] Fix | Delete
}
[200] Fix | Delete
} else {
[201] Fix | Delete
// Adding a new user to this site.
[202] Fix | Delete
$new_user_email = wp_unslash( $_REQUEST['email'] );
[203] Fix | Delete
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
[204] Fix | Delete
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
[205] Fix | Delete
$add_user_errors = $user_details['errors'];
[206] Fix | Delete
} else {
[207] Fix | Delete
/** This filter is documented in wp-includes/user.php */
[208] Fix | Delete
$new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
[209] Fix | Delete
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
[210] Fix | Delete
add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email.
[211] Fix | Delete
add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email.
[212] Fix | Delete
}
[213] Fix | Delete
wpmu_signup_user(
[214] Fix | Delete
$new_user_login,
[215] Fix | Delete
$new_user_email,
[216] Fix | Delete
array(
[217] Fix | Delete
'add_to_blog' => get_current_blog_id(),
[218] Fix | Delete
'new_role' => $_REQUEST['role'],
[219] Fix | Delete
)
[220] Fix | Delete
);
[221] Fix | Delete
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
[222] Fix | Delete
$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 ) );
[223] Fix | Delete
$new_user = wpmu_activate_signup( $key );
[224] Fix | Delete
if ( is_wp_error( $new_user ) ) {
[225] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' );
[226] Fix | Delete
} elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) {
[227] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' );
[228] Fix | Delete
} else {
[229] Fix | Delete
$redirect = add_query_arg(
[230] Fix | Delete
array(
[231] Fix | Delete
'update' => 'addnoconfirmation',
[232] Fix | Delete
'user_id' => $new_user['user_id'],
[233] Fix | Delete
),
[234] Fix | Delete
'user-new.php'
[235] Fix | Delete
);
[236] Fix | Delete
}
[237] Fix | Delete
} else {
[238] Fix | Delete
$redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' );
[239] Fix | Delete
}
[240] Fix | Delete
wp_redirect( $redirect );
[241] Fix | Delete
die();
[242] Fix | Delete
}
[243] Fix | Delete
}
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
$title = __( 'Add New User' );
[247] Fix | Delete
$parent_file = 'users.php';
[248] Fix | Delete
[249] Fix | Delete
$do_both = false;
[250] Fix | Delete
if ( is_multisite() && current_user_can( 'promote_users' ) && current_user_can( 'create_users' ) ) {
[251] Fix | Delete
$do_both = true;
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
$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>';
[255] Fix | Delete
[256] Fix | Delete
if ( is_multisite() ) {
[257] Fix | Delete
$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>' .
[258] Fix | Delete
'<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>';
[259] Fix | Delete
} else {
[260] Fix | Delete
$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>' .
[261] Fix | Delete
[262] Fix | Delete
'<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>';
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
$help .= '<p>' . __( 'Remember to click the Add New User button at the bottom of this screen when you are finished.' ) . '</p>';
[266] Fix | Delete
[267] Fix | Delete
get_current_screen()->add_help_tab(
[268] Fix | Delete
array(
[269] Fix | Delete
'id' => 'overview',
[270] Fix | Delete
'title' => __( 'Overview' ),
[271] Fix | Delete
'content' => $help,
[272] Fix | Delete
)
[273] Fix | Delete
);
[274] Fix | Delete
[275] Fix | Delete
get_current_screen()->add_help_tab(
[276] Fix | Delete
array(
[277] Fix | Delete
'id' => 'user-roles',
[278] Fix | Delete
'title' => __( 'User Roles' ),
[279] Fix | Delete
'content' => '<p>' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '</p>' .
[280] Fix | Delete
'<ul>' .
[281] Fix | Delete
'<li>' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '</li>' .
[282] Fix | Delete
'<li>' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '</li>' .
[283] Fix | Delete
'<li>' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '</li>' .
[284] Fix | Delete
'<li>' . __( 'Editors can publish posts, manage posts as well as manage other people&#8217;s posts, etc.' ) . '</li>' .
[285] Fix | Delete
'<li>' . __( 'Administrators have access to all the administration features.' ) . '</li>' .
[286] Fix | Delete
'</ul>',
[287] Fix | Delete
)
[288] Fix | Delete
);
[289] Fix | Delete
[290] Fix | Delete
get_current_screen()->set_help_sidebar(
[291] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[292] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/users-add-new-screen/">Documentation on Adding New Users</a>' ) . '</p>' .
[293] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
[294] Fix | Delete
);
[295] Fix | Delete
[296] Fix | Delete
wp_enqueue_script( 'wp-ajax-response' );
[297] Fix | Delete
wp_enqueue_script( 'user-profile' );
[298] Fix | Delete
[299] Fix | Delete
/**
[300] Fix | Delete
* Filters whether to enable user auto-complete for non-super admins in Multisite.
[301] Fix | Delete
*
[302] Fix | Delete
* @since 3.4.0
[303] Fix | Delete
*
[304] Fix | Delete
* @param bool $enable Whether to enable auto-complete for non-super admins. Default false.
[305] Fix | Delete
*/
[306] Fix | Delete
if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
[307] Fix | Delete
&& ( current_user_can( 'manage_network_users' ) || apply_filters( 'autocomplete_users_for_site_admins', false ) )
[308] Fix | Delete
) {
[309] Fix | Delete
wp_enqueue_script( 'user-suggest' );
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[313] Fix | Delete
[314] Fix | Delete
if ( isset( $_GET['update'] ) ) {
[315] Fix | Delete
$messages = array();
[316] Fix | Delete
if ( is_multisite() ) {
[317] Fix | Delete
$edit_link = '';
[318] Fix | Delete
if ( ( isset( $_GET['user_id'] ) ) ) {
[319] Fix | Delete
$user_id_new = absint( $_GET['user_id'] );
[320] Fix | Delete
if ( $user_id_new ) {
[321] Fix | Delete
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
[322] Fix | Delete
}
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
switch ( $_GET['update'] ) {
[326] Fix | Delete
case 'newuserconfirmation':
[327] Fix | Delete
$messages[] = __( 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.' );
[328] Fix | Delete
break;
[329] Fix | Delete
case 'add':
[330] Fix | Delete
$messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' );
[331] Fix | Delete
break;
[332] Fix | Delete
case 'addnoconfirmation':
[333] Fix | Delete
$message = __( 'User has been added to your site.' );
[334] Fix | Delete
[335] Fix | Delete
if ( $edit_link ) {
[336] Fix | Delete
$message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
$messages[] = $message;
[340] Fix | Delete
break;
[341] Fix | Delete
case 'addexisting':
[342] Fix | Delete
$messages[] = __( 'That user is already a member of this site.' );
[343] Fix | Delete
break;
[344] Fix | Delete
case 'could_not_add':
[345] Fix | Delete
$add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) );
[346] Fix | Delete
break;
[347] Fix | Delete
case 'created_could_not_add':
[348] Fix | Delete
$add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) );
[349] Fix | Delete
break;
[350] Fix | Delete
case 'does_not_exist':
[351] Fix | Delete
$add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) );
[352] Fix | Delete
break;
[353] Fix | Delete
case 'enter_email':
[354] Fix | Delete
$add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) );
[355] Fix | Delete
break;
[356] Fix | Delete
}
[357] Fix | Delete
} else {
[358] Fix | Delete
if ( 'add' === $_GET['update'] ) {
[359] Fix | Delete
$messages[] = __( 'User added.' );
[360] Fix | Delete
}
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
?>
[364] Fix | Delete
<div class="wrap">
[365] Fix | Delete
<h1 id="add-new-user">
[366] Fix | Delete
<?php
[367] Fix | Delete
if ( current_user_can( 'create_users' ) ) {
[368] Fix | Delete
_e( 'Add New User' );
[369] Fix | Delete
} elseif ( current_user_can( 'promote_users' ) ) {
[370] Fix | Delete
_e( 'Add Existing User' );
[371] Fix | Delete
}
[372] Fix | Delete
?>
[373] Fix | Delete
</h1>
[374] Fix | Delete
[375] Fix | Delete
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
[376] Fix | Delete
<div class="error">
[377] Fix | Delete
<ul>
[378] Fix | Delete
<?php
[379] Fix | Delete
foreach ( $errors->get_error_messages() as $err ) {
[380] Fix | Delete
echo "<li>$err</li>\n";
[381] Fix | Delete
}
[382] Fix | Delete
?>
[383] Fix | Delete
</ul>
[384] Fix | Delete
</div>
[385] Fix | Delete
<?php
[386] Fix | Delete
endif;
[387] Fix | Delete
[388] Fix | Delete
if ( ! empty( $messages ) ) {
[389] Fix | Delete
foreach ( $messages as $msg ) {
[390] Fix | Delete
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
[391] Fix | Delete
}
[392] Fix | Delete
}
[393] Fix | Delete
?>
[394] Fix | Delete
[395] Fix | Delete
<?php if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : ?>
[396] Fix | Delete
<div class="error">
[397] Fix | Delete
<?php
[398] Fix | Delete
foreach ( $add_user_errors->get_error_messages() as $message ) {
[399] Fix | Delete
echo "<p>$message</p>";
[400] Fix | Delete
}
[401] Fix | Delete
?>
[402] Fix | Delete
</div>
[403] Fix | Delete
<?php endif; ?>
[404] Fix | Delete
<div id="ajax-response"></div>
[405] Fix | Delete
[406] Fix | Delete
<?php
[407] Fix | Delete
if ( is_multisite() && current_user_can( 'promote_users' ) ) {
[408] Fix | Delete
if ( $do_both ) {
[409] Fix | Delete
echo '<h2 id="add-existing-user">' . __( 'Add Existing User' ) . '</h2>';
[410] Fix | Delete
}
[411] Fix | Delete
if ( ! current_user_can( 'manage_network_users' ) ) {
[412] Fix | Delete
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>';
[413] Fix | Delete
$label = __( 'Email' );
[414] Fix | Delete
$type = 'email';
[415] Fix | Delete
} else {
[416] Fix | Delete
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>';
[417] Fix | Delete
$label = __( 'Email or Username' );
[418] Fix | Delete
$type = 'text';
[419] Fix | Delete
}
[420] Fix | Delete
?>
[421] Fix | Delete
<form method="post" name="adduser" id="adduser" class="validate" novalidate="novalidate"
[422] Fix | Delete
<?php
[423] Fix | Delete
/**
[424] Fix | Delete
* Fires inside the adduser form tag.
[425] Fix | Delete
*
[426] Fix | Delete
* @since 3.0.0
[427] Fix | Delete
*/
[428] Fix | Delete
do_action( 'user_new_form_tag' );
[429] Fix | Delete
?>
[430] Fix | Delete
>
[431] Fix | Delete
<input name="action" type="hidden" value="adduser" />
[432] Fix | Delete
<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ); ?>
[433] Fix | Delete
[434] Fix | Delete
<table class="form-table" role="presentation">
[435] Fix | Delete
<tr class="form-field form-required">
[436] Fix | Delete
<th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
[437] Fix | Delete
<td><input name="email" type="<?php echo $type; ?>" id="adduser-email" class="wp-suggest-user" value="" /></td>
[438] Fix | Delete
</tr>
[439] Fix | Delete
<tr class="form-field">
[440] Fix | Delete
<th scope="row"><label for="adduser-role"><?php _e( 'Role' ); ?></label></th>
[441] Fix | Delete
<td><select name="role" id="adduser-role">
[442] Fix | Delete
<?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
[443] Fix | Delete
</select>
[444] Fix | Delete
</td>
[445] Fix | Delete
</tr>
[446] Fix | Delete
<?php if ( current_user_can( 'manage_network_users' ) ) { ?>
[447] Fix | Delete
<tr>
[448] Fix | Delete
<th scope="row"><?php _e( 'Skip Confirmation Email' ); ?></th>
[449] Fix | Delete
<td>
[450] Fix | Delete
<input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" />
[451] Fix | Delete
<label for="adduser-noconfirmation"><?php _e( 'Add the user without sending an email that requires their confirmation.' ); ?></label>
[452] Fix | Delete
</td>
[453] Fix | Delete
</tr>
[454] Fix | Delete
<?php } ?>
[455] Fix | Delete
</table>
[456] Fix | Delete
<?php
[457] Fix | Delete
/**
[458] Fix | Delete
* Fires at the end of the new user form.
[459] Fix | Delete
*
[460] Fix | Delete
* Passes a contextual string to make both types of new user forms
[461] Fix | Delete
* uniquely targetable. Contexts are 'add-existing-user' (Multisite),
[462] Fix | Delete
* and 'add-new-user' (single site and network admin).
[463] Fix | Delete
*
[464] Fix | Delete
* @since 3.7.0
[465] Fix | Delete
*
[466] Fix | Delete
* @param string $type A contextual string specifying which type of new user form the hook follows.
[467] Fix | Delete
*/
[468] Fix | Delete
do_action( 'user_new_form', 'add-existing-user' );
[469] Fix | Delete
?>
[470] Fix | Delete
<?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
[471] Fix | Delete
</form>
[472] Fix | Delete
<?php
[473] Fix | Delete
} // End if is_multisite().
[474] Fix | Delete
[475] Fix | Delete
if ( current_user_can( 'create_users' ) ) {
[476] Fix | Delete
if ( $do_both ) {
[477] Fix | Delete
echo '<h2 id="create-new-user">' . __( 'Add New User' ) . '</h2>';
[478] Fix | Delete
}
[479] Fix | Delete
?>
[480] Fix | Delete
<p><?php _e( 'Create a brand new user and add them to this site.' ); ?></p>
[481] Fix | Delete
<form method="post" name="createuser" id="createuser" class="validate" novalidate="novalidate"
[482] Fix | Delete
<?php
[483] Fix | Delete
/** This action is documented in wp-admin/user-new.php */
[484] Fix | Delete
do_action( 'user_new_form_tag' );
[485] Fix | Delete
?>
[486] Fix | Delete
>
[487] Fix | Delete
<input name="action" type="hidden" value="createuser" />
[488] Fix | Delete
<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ); ?>
[489] Fix | Delete
<?php
[490] Fix | Delete
// Load up the passed data, else set to a default.
[491] Fix | Delete
$creating = isset( $_POST['createuser'] );
[492] Fix | Delete
[493] Fix | Delete
$new_user_login = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
[494] Fix | Delete
$new_user_firstname = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
[495] Fix | Delete
$new_user_lastname = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
[496] Fix | Delete
$new_user_email = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
[497] Fix | Delete
$new_user_uri = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
[498] Fix | Delete
$new_user_role = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function