mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
User create/update rework. Introduce wp_insert_user(), wp_create_user(), wp_update_user(), add_user(), update_user(), wp_new_user_notification().
git-svn-id: https://develop.svn.wordpress.org/trunk@2872 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+5
-60
@@ -110,65 +110,10 @@ break;
|
||||
|
||||
case 'adduser':
|
||||
check_admin_referer();
|
||||
|
||||
$new_user_login = wp_specialchars(trim($_POST['user_login']));
|
||||
$new_pass1 = $_POST['pass1'];
|
||||
$new_pass2 = $_POST['pass2'];
|
||||
$new_user_email = wp_specialchars(trim($_POST['email']));
|
||||
$new_user_firstname = wp_specialchars(trim($_POST['firstname']));
|
||||
$new_user_lastname = wp_specialchars(trim($_POST['lastname']));
|
||||
$new_user_uri = wp_specialchars(trim($_POST['uri']));
|
||||
|
||||
$errors = array();
|
||||
|
||||
/* checking that username has been typed */
|
||||
if ($new_user_login == '')
|
||||
$errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
|
||||
|
||||
/* checking the password has been typed twice */
|
||||
do_action('check_passwords', array($new_user_login, &$new_pass1, &$new_pass2));
|
||||
if ($new_pass1 == '' || $new_pass2 == '')
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
|
||||
|
||||
/* checking the password has been typed twice the same */
|
||||
if ($new_pass1 != $new_pass2)
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
|
||||
|
||||
$new_user_nickname = $new_user_login;
|
||||
|
||||
if ( username_exists( $new_user_login ) )
|
||||
$errors['pass'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
|
||||
|
||||
/* checking e-mail address */
|
||||
if (empty($new_user_email)) {
|
||||
$errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
|
||||
} else if (!is_email($new_user_email)) {
|
||||
$errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
$user_ID = create_user( $new_user_login, $new_pass1, $new_user_email, 0 );
|
||||
|
||||
update_usermeta( $user_ID, 'first_name', $new_user_firstname);
|
||||
update_usermeta( $user_ID, 'last_name', $new_user_lastname);
|
||||
update_usermeta( $user_ID, 'first_name', $new_user_firstname);
|
||||
|
||||
$user = new WP_User($user_ID);
|
||||
$user->set_role(get_settings('default_role'));
|
||||
|
||||
$stars = '';
|
||||
for ($i = 0; $i < strlen($pass1); $i = $i + 1)
|
||||
$stars .= '*';
|
||||
$errors = add_user();
|
||||
|
||||
$user_login = stripslashes($new_user_login);
|
||||
$message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n";
|
||||
$message .= sprintf(__('Username: %s'), $new_user_login) . "\r\n\r\n";
|
||||
$message .= sprintf(__('E-mail: %s'), $new_user_email) . "\r\n";
|
||||
|
||||
@wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message);
|
||||
|
||||
do_action('user_register', $user_id);
|
||||
|
||||
if(count($errors) == 0) {
|
||||
header('Location: users.php?update=add');
|
||||
die();
|
||||
}
|
||||
@@ -310,11 +255,11 @@ $role_select .= '</select>';
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('First Name') ?> </th>
|
||||
<td><input name="firstname" type="text" id="firstname" value="<?php echo $new_user_firstname; ?>" /></td>
|
||||
<td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Last Name') ?> </th>
|
||||
<td><input name="lastname" type="text" id="lastname" value="<?php echo $new_user_lastname; ?>" /></td>
|
||||
<td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('E-mail') ?></th>
|
||||
@@ -322,7 +267,7 @@ $role_select .= '</select>';
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Website') ?></th>
|
||||
<td><input name="uri" type="text" id="uri" value="<?php echo $new_user_uri; ?>" /></td>
|
||||
<td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
$show_password_fields = apply_filters('show_password_fields', true);
|
||||
|
||||
Reference in New Issue
Block a user