Edit File by line
/home/barbar84/public_h.../wp-admin/network
File: user-new.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Add New User network administration panel.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Multisite
[5] Fix | Delete
* @since 3.1.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/** Load WordPress Administration Bootstrap */
[9] Fix | Delete
require_once __DIR__ . '/admin.php';
[10] Fix | Delete
[11] Fix | Delete
if ( ! current_user_can( 'create_users' ) ) {
[12] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to add users to this network.' ) );
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
get_current_screen()->add_help_tab(
[16] Fix | Delete
array(
[17] Fix | Delete
'id' => 'overview',
[18] Fix | Delete
'title' => __( 'Overview' ),
[19] Fix | Delete
'content' =>
[20] Fix | Delete
'<p>' . __( 'Add User will set up a new user account on the network and send that person an email with username and password.' ) . '</p>' .
[21] Fix | Delete
'<p>' . __( 'Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.' ) . '</p>',
[22] Fix | Delete
)
[23] Fix | Delete
);
[24] Fix | Delete
[25] Fix | Delete
get_current_screen()->set_help_sidebar(
[26] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[27] Fix | Delete
'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>' ) . '</p>' .
[28] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'
[29] Fix | Delete
);
[30] Fix | Delete
[31] Fix | Delete
if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
[32] Fix | Delete
check_admin_referer( 'add-user', '_wpnonce_add-user' );
[33] Fix | Delete
[34] Fix | Delete
if ( ! current_user_can( 'manage_network_users' ) ) {
[35] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
if ( ! is_array( $_POST['user'] ) ) {
[39] Fix | Delete
wp_die( __( 'Cannot create an empty user.' ) );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
$user = wp_unslash( $_POST['user'] );
[43] Fix | Delete
[44] Fix | Delete
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
[45] Fix | Delete
[46] Fix | Delete
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
[47] Fix | Delete
$add_user_errors = $user_details['errors'];
[48] Fix | Delete
} else {
[49] Fix | Delete
$password = wp_generate_password( 12, false );
[50] Fix | Delete
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ) );
[51] Fix | Delete
[52] Fix | Delete
if ( ! $user_id ) {
[53] Fix | Delete
$add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
[54] Fix | Delete
} else {
[55] Fix | Delete
/**
[56] Fix | Delete
* Fires after a new user has been created via the network user-new.php page.
[57] Fix | Delete
*
[58] Fix | Delete
* @since 4.4.0
[59] Fix | Delete
*
[60] Fix | Delete
* @param int $user_id ID of the newly created user.
[61] Fix | Delete
*/
[62] Fix | Delete
do_action( 'network_user_new_created_user', $user_id );
[63] Fix | Delete
[64] Fix | Delete
wp_redirect(
[65] Fix | Delete
add_query_arg(
[66] Fix | Delete
array(
[67] Fix | Delete
'update' => 'added',
[68] Fix | Delete
'user_id' => $user_id,
[69] Fix | Delete
),
[70] Fix | Delete
'user-new.php'
[71] Fix | Delete
)
[72] Fix | Delete
);
[73] Fix | Delete
exit;
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if ( isset( $_GET['update'] ) ) {
[79] Fix | Delete
$messages = array();
[80] Fix | Delete
if ( 'added' === $_GET['update'] ) {
[81] Fix | Delete
$edit_link = '';
[82] Fix | Delete
if ( isset( $_GET['user_id'] ) ) {
[83] Fix | Delete
$user_id_new = absint( $_GET['user_id'] );
[84] Fix | Delete
if ( $user_id_new ) {
[85] 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 ) ) );
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$message = __( 'User added.' );
[90] Fix | Delete
[91] Fix | Delete
if ( $edit_link ) {
[92] Fix | Delete
$message .= sprintf( ' <a href="%s">%s</a>', $edit_link, __( 'Edit user' ) );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
$messages[] = $message;
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
$title = __( 'Add New User' );
[100] Fix | Delete
$parent_file = 'users.php';
[101] Fix | Delete
[102] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
[103] Fix | Delete
[104] Fix | Delete
<div class="wrap">
[105] Fix | Delete
<h1 id="add-new-user"><?php _e( 'Add New User' ); ?></h1>
[106] Fix | Delete
<?php
[107] Fix | Delete
if ( ! empty( $messages ) ) {
[108] Fix | Delete
foreach ( $messages as $msg ) {
[109] Fix | Delete
echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) {
[114] Fix | Delete
?>
[115] Fix | Delete
<div class="error">
[116] Fix | Delete
<?php
[117] Fix | Delete
foreach ( $add_user_errors->get_error_messages() as $message ) {
[118] Fix | Delete
echo "<p>$message</p>";
[119] Fix | Delete
}
[120] Fix | Delete
?>
[121] Fix | Delete
</div>
[122] Fix | Delete
<?php } ?>
[123] Fix | Delete
<form action="<?php echo network_admin_url( 'user-new.php?action=add-user' ); ?>" id="adduser" method="post" novalidate="novalidate">
[124] Fix | Delete
<table class="form-table" role="presentation">
[125] Fix | Delete
<tr class="form-field form-required">
[126] Fix | Delete
<th scope="row"><label for="username"><?php _e( 'Username' ); ?></label></th>
[127] Fix | Delete
<td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" /></td>
[128] Fix | Delete
</tr>
[129] Fix | Delete
<tr class="form-field form-required">
[130] Fix | Delete
<th scope="row"><label for="email"><?php _e( 'Email' ); ?></label></th>
[131] Fix | Delete
<td><input type="email" class="regular-text" name="user[email]" id="email"/></td>
[132] Fix | Delete
</tr>
[133] Fix | Delete
<tr class="form-field">
[134] Fix | Delete
<td colspan="2" class="td-full"><?php _e( 'A password reset link will be sent to the user via email.' ); ?></td>
[135] Fix | Delete
</tr>
[136] Fix | Delete
</table>
[137] Fix | Delete
<?php
[138] Fix | Delete
/**
[139] Fix | Delete
* Fires at the end of the new user form in network admin.
[140] Fix | Delete
*
[141] Fix | Delete
* @since 4.5.0
[142] Fix | Delete
*/
[143] Fix | Delete
do_action( 'network_user_new_form' );
[144] Fix | Delete
[145] Fix | Delete
wp_nonce_field( 'add-user', '_wpnonce_add-user' );
[146] Fix | Delete
submit_button( __( 'Add User' ), 'primary', 'add-user' );
[147] Fix | Delete
?>
[148] Fix | Delete
</form>
[149] Fix | Delete
</div>
[150] Fix | Delete
<?php
[151] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[152] Fix | Delete
[153] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function