Changeset 2872
- Timestamp:
- 09/14/2005 12:03:02 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2866 r2872 343 343 344 344 return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 345 } 346 347 // Creates a new user from the "Users" form using $_POST information. 348 349 function add_user() { 350 return update_user(); 351 } 352 353 function update_user($user_id = 0) { 354 355 if ( $user_id != 0 ) { 356 $update = true; 357 $user->ID = $user_id; 358 $userdata = get_userdata($user_id); 359 $user->user_login = $userdata->user_login; 360 } else { 361 $update = false; 362 $user = ''; 363 } 364 365 if ( isset($_POST['user_login']) ) 366 $user->user_login = wp_specialchars(trim($_POST['user_login'])); 367 368 $pass1 = $pass2 = ''; 369 if ( isset($_POST['pass1']) ) 370 $pass1 = $_POST['pass1']; 371 if ( isset($_POST['pass2']) ) 372 $pass2 = $_POST['pass2']; 373 374 if ( isset($_POST['email']) ) 375 $user->user_email = wp_specialchars(trim($_POST['email'])); 376 if ( isset($_POST['url']) ) { 377 $user->user_url = wp_specialchars(trim($_POST['url'])); 378 $user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; 379 } 380 if ( isset($_POST['first_name']) ) 381 $user->first_name = wp_specialchars(trim($_POST['first_name'])); 382 if ( isset($_POST['last_name']) ) 383 $user->last_name = wp_specialchars(trim($_POST['last_name'])); 384 if ( isset($_POST['nickname']) ) 385 $user->nickname = wp_specialchars(trim($_POST['nickname'])); 386 if ( isset($_POST['display_name']) ) 387 $user->display_name = wp_specialchars(trim($_POST['display_name'])); 388 if ( isset($_POST['description']) ) 389 $user->description = wp_specialchars(trim($_POST['description'])); 390 if ( isset($_POST['jabber']) ) 391 $user->jabber = wp_specialchars(trim($_POST['jabber'])); 392 if ( isset($_POST['aim']) ) 393 $user->aim = wp_specialchars(trim($_POST['aim'])); 394 if ( isset($_POST['yim']) ) 395 $user->yim = wp_specialchars(trim($_POST['yim'])); 396 397 $errors = array(); 398 399 /* checking that username has been typed */ 400 if ($user->user_login == '') 401 $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.'); 402 403 /* checking the password has been typed twice */ 404 do_action('check_passwords', array($user->user_login, &$pass1, &$pass2)); 405 406 if ( !$update ) { 407 if ( $pass1 == '' || $pass2 == '' ) 408 $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.'); 409 } else { 410 if ( ( empty($pass1) && !empty($pass2) ) || ( empty($pass2) && !empty($pass1) ) ) 411 $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); 412 } 413 414 /* checking the password has been typed twice the same */ 415 if ($pass1 != $pass2) 416 $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.'); 417 418 if ( !empty($pass1) ) 419 $user->user_pass = $pass1; 420 421 if ( !$update && username_exists( $user_login ) ) 422 $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 423 424 /* checking e-mail address */ 425 if (empty($user->user_email)) { 426 $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address"); 427 } else if (!is_email($user->user_email)) { 428 $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); 429 } 430 431 if ( count($errors) != 0 ) 432 return $errors; 433 434 if ( $update ) { 435 $user_id = wp_update_user(get_object_vars($user)); 436 } else { 437 $user_id = wp_insert_user(get_object_vars($user)); 438 wp_new_user_notification($user_id); 439 } 440 441 return $errors; 345 442 } 346 443 -
trunk/wp-admin/admin.php
r2865 r2872 7 7 require_once(ABSPATH . 'wp-admin/admin-functions.php'); 8 8 require_once(ABSPATH . 'wp-admin/admin-db.php'); 9 require_once(ABSPATH . WPINC . '/registration-functions.php'); 10 9 11 auth_redirect(); 10 12 -
trunk/wp-admin/import/mt.php
r2800 r2872 36 36 $importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata); 37 37 $this->posts = explode("--MT-ENTRY--", $importdata); 38 unset($importdata); 39 40 38 41 } 39 42 … … 42 45 if ('' == MTEXPORT) die("You must edit the MTEXPORT line as described on the <a href='import-mt.php'>previous page</a> to continue."); 43 46 44 $this->get_entries(); 47 $this->get_entries(); 45 48 } 46 49 -
trunk/wp-admin/profile-update.php
r2845 r2872 5 5 check_admin_referer(); 6 6 7 if ( empty($_POST['email']) ) 8 die (__("<strong>ERROR</strong>: please type your e-mail address")); 9 elseif ( !is_email($_POST['email']) ) 10 die (__("<strong>ERROR</strong>: the e-mail address isn't correct")); 7 $errors = update_user($user_ID); 11 8 12 $pass1 = $_POST['pass1']; 13 $pass2 = $_POST['pass2']; 14 do_action('check_passwords', array($user_login, &$pass1, &$pass2)); 15 16 if ( '' == $pass1 ) { 17 if ( '' != $pass2 ) 18 die (__('<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice.')); 19 $updatepassword = ''; 20 } else { 21 if ('' == $pass2) 22 die (__('<strong>ERROR</strong>: you typed your new password only once. Go back to type it twice.')); 23 if ( $pass1 != $pass2 ) 24 die (__('<strong>ERROR</strong>: you typed two different passwords. Go back to correct that.')); 25 $newuser_pass = $pass1; 26 $updatepassword = "user_pass=MD5('$newuser_pass'), "; 27 wp_clearcookie(); 28 wp_setcookie($user_login, $newuser_pass); 9 if (count($errors) != 0) { 10 foreach ($errors as $id => $error) { 11 echo $error . '<br/>'; 12 } 13 exit; 29 14 } 30 31 $first_name = wp_specialchars($_POST['first_name']);32 $last_name = wp_specialchars($_POST['last_name']);33 $display_name = wp_specialchars($_POST['display_name']);34 $nickname = $_POST['nickname'];35 $nicename = sanitize_title($nickname);36 $jabber = wp_specialchars($_POST['jabber']);37 $aim = wp_specialchars($_POST['aim']);38 $yim = wp_specialchars($_POST['yim']);39 $email = wp_specialchars($_POST['email']);40 $url = wp_specialchars($_POST['url']);41 $url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $url) ? $url : 'http://' . $url;42 $user_description = $_POST['user_description'];43 44 $result = $wpdb->query("UPDATE $wpdb->users SET $updatepassword user_email='$email', user_url='$url', user_nicename = '$nicename', display_name = '$display_name' WHERE ID = '$user_ID'");45 46 update_usermeta( $user_ID, 'first_name', $first_name );47 update_usermeta( $user_ID, 'last_name', $last_name );48 update_usermeta( $user_ID, 'nickname', $nickname );49 update_usermeta( $user_ID, 'description', $user_description );50 update_usermeta( $user_ID, 'jabber', $jabber );51 update_usermeta( $user_ID, 'aim', $aim );52 update_usermeta( $user_ID, 'yim', $yim );53 54 do_action('profile_update', $user_ID);55 15 56 16 if ( 'profile' == $_POST['from'] ) -
trunk/wp-admin/profile.php
r2844 r2872 29 29 <legend><?php _e('Name'); ?></legend> 30 30 <p><label><?php _e('Username: (no editing)'); ?><br /> 31 <input type="text" name="user name" value="<?php echo $profiledata->user_login; ?>" disabled="disabled" />31 <input type="text" name="user_login" value="<?php echo $profiledata->user_login; ?>" disabled="disabled" /> 32 32 </label></p> 33 33 <p><label><?php _e('First name:') ?><br /> … … 84 84 <legend><?php _e('About yourself'); ?></legend> 85 85 <p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p> 86 <p><textarea name=" user_description" rows="5" cols="30"><?php echo $profiledata->user_description ?></textarea></p>86 <p><textarea name="description" rows="5" cols="30"><?php echo $profiledata->description ?></textarea></p> 87 87 </fieldset> 88 88 -
trunk/wp-admin/user-edit.php
r2762 r2872 34 34 35 35 $errors = array(); 36 if(empty($wp_user)) {37 $wp_user = new WP_User($user_id);38 $edituser = &$wp_user->data;39 }40 36 41 if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.'); 42 43 /* checking the nickname has been typed */ 44 if (empty($_POST["new_nickname"])) { 45 $errors['nickname'] = __("<strong>ERROR</strong>: please enter your nickname (can be the same as your username)"); 46 } 47 48 $new_user_login = wp_specialchars($_POST['new_user_login']); 49 $pass1 = $_POST['pass1']; 50 $pass2 = $_POST['pass2']; 51 do_action('check_passwords', array($new_user_login, &$pass1, &$pass2)); 52 53 if ( '' == $pass1 ) { 54 if ( '' != $pass2 ) 55 $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); 56 $updatepassword = ''; 57 } else { 58 if ( '' == $pass2) 59 $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); 60 if ( $pass1 != $pass2 ) 61 $errors['pass'] = __("<strong>ERROR</strong>: you typed two different passwords."); 62 $new_pass = $pass1; 63 $updatepassword = "user_pass=MD5('$new_pass'), "; 64 } 65 66 $edituser->user_login = wp_specialchars($_POST['new_user_login']); 67 $edituser->user_nicename = sanitize_title($new_nickname, $user_id); 68 $edituser->user_email = wp_specialchars($_POST['new_email']); 69 $edituser->user_url = wp_specialchars($_POST['new_url']); 70 $edituser->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $edituser->user_url) ? $edituser->user_url : 'http://' . $edituser->user_url; 71 $edituser->display_name = wp_specialchars($_POST['display_name']); 72 73 $edituser->first_name = wp_specialchars($_POST['new_firstname']); 74 $edituser->last_name = wp_specialchars($_POST['new_lastname']); 75 $edituser->nickname = $_POST['new_nickname']; 76 $edituser->icq = wp_specialchars($_POST['new_icq']); 77 $edituser->aim = wp_specialchars($_POST['new_aim']); 78 $edituser->msn = wp_specialchars($_POST['new_msn']); 79 $edituser->yim = wp_specialchars($_POST['new_yim']); 80 $edituser->description = $_POST['new_description']; 37 if (!current_user_can('edit_users')) 38 $errors['head'] = __('You do not have permission to edit this user.'); 39 else 40 $errors = update_user($user_id); 81 41 82 42 if(count($errors) == 0) { 83 $result = $wpdb->query("UPDATE $wpdb->users SET user_login = '$edituser->user_login', $updatepassword user_email='$edituser->user_email', user_url='$edituser->user_url', user_nicename = '$edituser->user_nicename', display_name = '$edituser->display_name' WHERE ID = '$user_id'");84 85 update_usermeta( $user_id, 'first_name', $edituser->firstname );86 update_usermeta( $user_id, 'last_name', $edituser->lastname );87 update_usermeta( $user_id, 'nickname', $edituser->nickname );88 update_usermeta( $user_id, 'description', $edituser->description );89 update_usermeta( $user_id, 'icq', $edituser->icq );90 update_usermeta( $user_id, 'aim', $edituser->aim );91 update_usermeta( $user_id, 'msn', $edituser->msn );92 update_usermeta( $user_id, 'yim', $edituser->yim );93 94 $wp_user->set_role($_POST['new_role']);95 96 43 header("Location: user-edit.php?user_id=$user_id&updated=true"); 97 } else { 98 $wp_user->roles = array($_POST['new_role'] => true); 44 exit; 99 45 } 100 46 … … 102 48 include ('admin-header.php'); 103 49 104 if(empty($wp_user)) { 105 $wp_user = new WP_User($user_id); 106 $edituser = &$wp_user->data; 107 } 50 $profileuser = new WP_User($user_id); 51 $profiledata = $profileuser->data; 108 52 109 53 if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.'); … … 115 59 </div> 116 60 <?php endif; ?> 117 <?php if ( isset($errors)) : ?>61 <?php if ( count($errors) != 0 ) : ?> 118 62 <div class="error"> 119 63 <ul> … … 127 71 <div class="wrap"> 128 72 <h2><?php _e('Edit User'); ?></h2> 129 <form name="edituser" id="edituser" action="user-edit.php" method="post"> 130 <table width="99%" border="0" cellspacing="2" cellpadding="3"> 131 <tr> 132 <th width="33%" scope="row"><?php _e('Username:') ?></th> 133 <td width="73%"><input type="text" name="new_user_login" id="new_user_login" value="<?php echo $edituser->user_login; ?>" /></td> 134 </tr> 135 <tr> 136 <th scope="row"><?php _e('Role:') ?></th> 137 <td><select name="new_role" id="new_role"><?php 138 foreach($wp_roles->role_names as $role => $name) { 139 $selected = (empty($wp_user->roles[$role])) ? '' : 'selected="selected"'; 140 echo "<option {$selected} value=\"{$role}\">{$name}</option>"; 141 } 142 ?></select></td> 143 </tr> 144 <tr> 145 <th scope="row"><?php _e('Posts:') ?></th> 146 <td><?php echo get_usernumposts($edituser->ID); ?></td> 147 </tr> 148 <?php if ( isset($edituser->user_registered) && ('0000-00-00 00:00:00' != $edituser->user_registered) ) { ?> 149 <tr> 150 <th scope="row"><?php _e('Registered on:') ?></th> 151 <td><?php echo substr($edituser->user_registered, 0, 11); ?></td> 152 </tr> 153 <?php } ?> 154 <tr> 155 <th scope="row"><?php _e('First name:') ?></th> 156 <td><input type="text" name="new_firstname" id="new_firstname" value="<?php echo $edituser->first_name ?>" /></td> 157 </tr> 158 <tr> 159 <th scope="row"><?php _e('Last name:') ?></th> 160 <td><input type="text" name="new_lastname" id="new_lastname2" value="<?php echo $edituser->last_name ?>" /></td> 161 </tr> 162 <tr> 163 <th scope="row"><?php _e('Profile:') ?></th> 164 <td><textarea name="new_description" rows="5" id="new_description" style="width: 99%; "><?php echo $edituser->description ?></textarea></td> 165 </tr> 166 <tr> 167 <th scope="row"><?php _e('Nickname:') ?></th> 168 <td><input type="text" name="new_nickname" id="new_nickname" value="<?php echo $edituser->nickname ?>" /></td> 169 </tr> 170 <tr> 171 <th scope="row"><?php _e('E-mail:') ?></th> 172 <td><input type="text" name="new_email" id="new_email" value="<?php echo $edituser->user_email ?>" /></td> 173 </tr> 174 <tr> 175 <th scope="row"><?php _e('Website:') ?></th> 176 <td><input type="text" name="new_url" id="new_url" value="<?php echo $edituser->user_url ?>" /></td> 177 </tr> 178 <tr> 179 <th scope="row"><?php _e('ICQ:') ?></th> 180 <td><input type="text" name="new_icq" id="new_icq" value="<?php if ($edituser->icq > 0) { echo $edituser->icq; } ?>" /></td> 181 </tr> 182 <tr> 183 <th scope="row"><?php _e('AIM:') ?></th> 184 <td><input type="text" name="new_aim" id="new_aim" value="<?php echo $edituser->aim ?>" /></td> 185 </tr> 186 <tr> 187 <th scope="row"><?php _e('MSN IM:') ?> 188 </th> 189 <td><input type="text" name="new_msn" id="new_msn" value="<?php echo $edituser->msn ?>" /></td> 190 </tr> 191 <tr> 192 <th scope="row"><?php _e('Yahoo IM:') ?> 193 </th> 194 <td><input type="text" name="new_yim" id="new_yim" value="<?php echo $edituser->yim ?>" /> 195 </td> 196 </tr> 197 <tr> 198 <th scope="row"><?php _e('Identity on blog:') ?> 199 </th> 200 <td> <select name="display_name"> 201 <option value="<?php echo $edituser->display_name; ?>"><?php echo $edituser->display_name; ?></option> 202 <option value="<?php echo $edituser->nickname ?>"><?php echo $edituser->nickname ?></option> 203 <option value="<?php echo $edituser->user_login ?>"><?php echo $edituser->user_login ?></option> 204 <?php if ( !empty( $edituser->first_name ) ) : ?> 205 <option value="<?php echo $edituser->first_name ?>"><?php echo $edituser->first_name ?></option> 206 <?php endif; ?> 207 <?php if ( !empty( $edituser->last_name ) ) : ?> 208 <option value="<?php echo $edituser->last_name ?>"><?php echo $edituser->last_name ?></option> 209 <?php endif; ?> 210 <?php if ( !empty( $edituser->first_name ) && !empty( $edituser->last_name ) ) : ?> 211 <option value="<?php echo $edituser->first_name." ".$edituser->last_name ?>"><?php echo $edituser->first_name." ".$edituser->last_name ?></option> 212 <option value="<?php echo $edituser->last_name." ".$edituser->first_name ?>"><?php echo $edituser->last_name." ".$edituser->first_name ?></option> 213 <?php endif; ?> 214 </select> 215 </td> 216 </tr> 73 74 <form name="profile" id="your-profile" action="user-edit.php" method="post"> 75 <p> 76 <input type="hidden" name="from" value="profile" /> 77 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 78 </p> 79 80 <fieldset> 81 <legend><?php _e('Name'); ?></legend> 82 <p><label><?php _e('Username: (no editing)'); ?><br /> 83 <input type="text" name="user_login" value="<?php echo $profiledata->user_login; ?>" disabled="disabled" /> 84 </label></p> 85 <p><label><?php _e('First name:') ?><br /> 86 <input type="text" name="first_name" value="<?php echo $profiledata->first_name ?>" /></label></p> 87 88 <p><label><?php _e('Last name:') ?><br /> 89 <input type="text" name="last_name" value="<?php echo $profiledata->last_name ?>" /></label></p> 90 91 <p><label><?php _e('Nickname:') ?><br /> 92 <input type="text" name="nickname" value="<?php echo $profiledata->nickname ?>" /></label></p> 93 94 </p><label><?php _e('Display name publicly as:') ?> <br /> 95 <select name="display_name"> 96 <option value="<?php echo $profiledata->display_name; ?>"><?php echo $profiledata->display_name; ?></option> 97 <option value="<?php echo $profiledata->nickname ?>"><?php echo $profiledata->nickname ?></option> 98 <option value="<?php echo $profiledata->user_login ?>"><?php echo $profiledata->user_login ?></option> 99 <?php if ( !empty( $profiledata->first_name ) ) : ?> 100 <option value="<?php echo $profiledata->first_name ?>"><?php echo $profiledata->first_name ?></option> 101 <?php endif; ?> 102 <?php if ( !empty( $profiledata->last_name ) ) : ?> 103 <option value="<?php echo $profiledata->last_name ?>"><?php echo $profiledata->last_name ?></option> 104 <?php endif; ?> 105 <?php if ( !empty( $profiledata->first_name ) && !empty( $profiledata->last_name ) ) : ?> 106 <option value="<?php echo $profiledata->first_name." ".$profiledata->last_name ?>"><?php echo $profiledata->first_name." ".$profiledata->last_name ?></option> 107 <option value="<?php echo $profiledata->last_name." ".$profiledata->first_name ?>"><?php echo $profiledata->last_name." ".$profiledata->first_name ?></option> 108 <?php endif; ?> 109 </select></label></p> 110 </fieldset> 111 112 <fieldset> 113 <legend><?php _e('Contact Info'); ?></legend> 114 115 <p><label><?php _e('E-mail: (required)') ?><br /> 116 <input type="text" name="email" value="<?php echo $profiledata->user_email ?>" /></label></p> 117 118 <p><label><?php _e('Website:') ?><br /> 119 <input type="text" name="url" value="<?php echo $profiledata->user_url ?>" /> 120 </label></p> 121 122 <p><label><?php _e('AIM:') ?><br /> 123 <input type="text" name="aim" value="<?php echo $profiledata->aim ?>" /> 124 </label></p> 125 126 <p><label><?php _e('Yahoo IM:') ?><br /> 127 <input type="text" name="yim" value="<?php echo $profiledata->yim ?>" /> 128 </label></p> 129 130 <p><label><?php _e('Jabber / Google Talk:') ?> 131 <input type="text" name="jabber" value="<?php echo $profiledata->jabber ?>" /></label> 132 </p> 133 </fieldset> 134 <br clear="all" /> 135 <fieldset> 136 <legend><?php _e('About the user'); ?></legend> 137 <p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p> 138 <p><textarea name="description" rows="5" cols="30"><?php echo $profiledata->description ?></textarea></p> 139 </fieldset> 140 217 141 <?php 218 do_action('edit_user_profile');219 220 142 $show_password_fields = apply_filters('show_password_fields', true); 221 143 if ( $show_password_fields ) : 222 144 ?> 223 <tr> 224 <th scope="row"><?php _e('New <strong>Password</strong> (Leave blank to stay the same.)') ?></th> 225 <td><input type="password" name="pass1" size="16" value="" /> 226 <br /> 227 <input type="password" name="pass2" size="16" value="" /></td> 228 </tr> 145 <fieldset> 146 <legend><?php _e("Update User's Password"); ?></legend> 147 <p class="desc"><?php _e("If you would like to change the user's password type a new one twice below. Otherwise leave this blank."); ?></p> 148 <p><label><?php _e('New Password:'); ?><br /> 149 <input type="password" name="pass1" size="16" value="" /> 150 </label></p> 151 <p><label><?php _e('Type it one more time:'); ?><br /> 152 <input type="password" name="pass2" size="16" value="" /> 153 </label></p> 154 </fieldset> 229 155 <?php endif; ?> 230 </table> 231 <p class="submit"> 156 157 <?php do_action('edit_user_profile'); ?> 158 159 <br clear="all" /> 160 <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform"> 161 <?php 162 if(count($profileuser->caps) > count($profileuser->roles)): 163 ?> 164 <tr> 165 <th scope="row"><?php _e('Additional Capabilities:') ?></th> 166 <td><?php 167 $output = ''; 168 foreach($profileuser->caps as $cap => $value) { 169 if(!$wp_roles->is_role($cap)) { 170 if($output != '') $output .= ', '; 171 $output .= $value ? $cap : "Denied: {$cap}"; 172 } 173 } 174 echo $output; 175 ?></td> 176 </tr> 177 <?php 178 endif; 179 ?> 180 </table> 181 <p class="submit"> 232 182 <input type="hidden" name="action" value="update" /> 233 183 <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" /> 234 184 <input type="submit" value="<?php _e('Update User »') ?>" name="submit" /> 235 185 </p> 236 186 </form> 237 187 </div> 238 239 188 <?php 240 189 break; -
trunk/wp-admin/users.php
r2847 r2872 111 111 case 'adduser': 112 112 check_admin_referer(); 113 114 $new_user_login = wp_specialchars(trim($_POST['user_login'])); 115 $new_pass1 = $_POST['pass1']; 116 $new_pass2 = $_POST['pass2']; 117 $new_user_email = wp_specialchars(trim($_POST['email'])); 118 $new_user_firstname = wp_specialchars(trim($_POST['firstname'])); 119 $new_user_lastname = wp_specialchars(trim($_POST['lastname'])); 120 $new_user_uri = wp_specialchars(trim($_POST['uri'])); 121 122 $errors = array(); 123 124 /* checking that username has been typed */ 125 if ($new_user_login == '') 126 $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.'); 127 128 /* checking the password has been typed twice */ 129 do_action('check_passwords', array($new_user_login, &$new_pass1, &$new_pass2)); 130 if ($new_pass1 == '' || $new_pass2 == '') 131 $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.'); 132 133 /* checking the password has been typed twice the same */ 134 if ($new_pass1 != $new_pass2) 135 $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.'); 136 137 $new_user_nickname = $new_user_login; 138 139 if ( username_exists( $new_user_login ) ) 140 $errors['pass'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 141 142 /* checking e-mail address */ 143 if (empty($new_user_email)) { 144 $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address"); 145 } else if (!is_email($new_user_email)) { 146 $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); 147 } 148 149 if(count($errors) == 0) { 150 $user_ID = create_user( $new_user_login, $new_pass1, $new_user_email, 0 ); 151 152 update_usermeta( $user_ID, 'first_name', $new_user_firstname); 153 update_usermeta( $user_ID, 'last_name', $new_user_lastname); 154 update_usermeta( $user_ID, 'first_name', $new_user_firstname); 155 156 $user = new WP_User($user_ID); 157 $user->set_role(get_settings('default_role')); 158 159 $stars = ''; 160 for ($i = 0; $i < strlen($pass1); $i = $i + 1) 161 $stars .= '*'; 162 163 $user_login = stripslashes($new_user_login); 164 $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; 165 $message .= sprintf(__('Username: %s'), $new_user_login) . "\r\n\r\n"; 166 $message .= sprintf(__('E-mail: %s'), $new_user_email) . "\r\n"; 167 168 @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); 169 170 do_action('user_register', $user_id); 171 113 114 $errors = add_user(); 115 116 if(count($errors) == 0) { 172 117 header('Location: users.php?update=add'); 173 118 die(); … … 311 256 <tr> 312 257 <th scope="row"><?php _e('First Name') ?> </th> 313 <td><input name="first name" type="text" id="firstname" value="<?php echo $new_user_firstname; ?>" /></td>258 <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td> 314 259 </tr> 315 260 <tr> 316 261 <th scope="row"><?php _e('Last Name') ?> </th> 317 <td><input name="last name" type="text" id="lastname" value="<?php echo $new_user_lastname; ?>" /></td>262 <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td> 318 263 </tr> 319 264 <tr> … … 323 268 <tr> 324 269 <th scope="row"><?php _e('Website') ?></th> 325 <td><input name="ur i" type="text" id="uri" value="<?php echo $new_user_uri; ?>" /></td>270 <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td> 326 271 </tr> 327 272 <?php -
trunk/wp-includes/functions.php
r2856 r2872 1264 1264 } 1265 1265 1266 function clean_user_cache($id) { 1267 if ( isset( $cache_userdata[$id] ) ) 1268 unset( $cache_userdata[$id] ); 1269 } 1270 1266 1271 function wp_head() { 1267 1272 do_action('wp_head'); -
trunk/wp-includes/pluggable-functions.php
r2827 r2872 320 320 endif; 321 321 322 if ( !function_exists('wp_new_user_notification') ) : 323 function wp_new_user_notification($user_id, $plaintext_pass = '') { 324 $user = new WP_User($user_id); 325 326 $stars = ''; 327 for ($i = 0; $i < strlen($pass1); $i = $i + 1) 328 $stars .= '*'; 329 330 $user_login = stripslashes($user->data->user_login); 331 $user_email = stripslashes($user->data->user_email); 332 333 $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; 334 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 335 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; 336 337 @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); 338 339 if ( empty($plaintext_pass) ) 340 return; 341 342 $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; 343 $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; 344 $message .= get_settings('siteurl') . "/wp-login.php\r\n"; 345 346 wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); 347 348 } 349 endif; 350 322 351 ?> -
trunk/wp-includes/registration-functions.php
r2735 r2872 9 9 } 10 10 11 function create_user( $username, $password, $email, $user_level) {11 function wp_insert_user($userdata) { 12 12 global $wpdb; 13 $username = $wpdb->escape( $username );14 $email = $wpdb->escape( $email );15 $password = md5( $password );16 $user_nicename = sanitize_title( $username );17 $now = gmdate('Y-m-d H:i:s');18 13 19 $query = "INSERT INTO $wpdb->users 20 (user_login, user_pass, user_email, user_registered, user_nicename, display_name) 14 extract($userdata); 15 16 // Are we updating or creating? 17 if ( !empty($ID) ) { 18 $update = true; 19 } else { 20 $update = false; 21 // Password is not hashed when creating new user. 22 $user_pass = md5($user_pass); 23 } 24 25 if ( empty($user_nicename) ) 26 $user_nicename = sanitize_title( $user_login ); 27 28 if ( empty($display_name) ) 29 $display_name = $user_login; 30 31 if ( empty($nickname) ) 32 $nickname = $user_login; 33 34 if ( empty($user_registered) ) 35 $user_registered = gmdate('Y-m-d H:i:s'); 36 37 if ( $update ) { 38 $query = "UPDATE $wpdb->users SET user_pass='$user_pass' user_email='$user_email', user_url='$user_url', user_nicename = '$user_nicename', display_name = '$display_name' WHERE ID = '$ID'"; 39 $query = apply_filters('update_user_query', $query); 40 $wpdb->query( $query ); 41 $user_id = $ID; 42 } else { 43 $query = "INSERT INTO $wpdb->users 44 (user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name) 21 45 VALUES 22 ('$username', '$password', '$email', '$now', '$user_nicename', '$username')"; 23 $query = apply_filters('create_user_query', $query); 24 $wpdb->query( $query ); 25 $user_id = $wpdb->insert_id; 46 ('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')"; 47 $query = apply_filters('create_user_query', $query); 48 $wpdb->query( $query ); 49 $user_id = $wpdb->insert_id; 50 } 51 52 clean_user_cache($user_id); 53 clean_user_cache($user_login); 26 54 27 $user_level = (int) $user_level; 28 update_usermeta( $user_id, $wpdb->prefix . 'user_level', $user_level); 29 $user = new WP_User($user_id); 30 $user->set_role(get_settings('default_role')); 55 update_usermeta( $user_id, 'first_name', $first_name); 56 update_usermeta( $user_id, 'last_name', $last_name); 57 update_usermeta( $user_id, 'nickname', $nickname ); 58 update_usermeta( $user_id, 'description', $description ); 59 update_usermeta( $user_id, 'jabber', $jabber ); 60 update_usermeta( $user_id, 'aim', $aim ); 61 update_usermeta( $user_id, 'yim', $yim ); 62 63 if ( !$update ) { 64 $user = new WP_User($user_id); 65 $user->set_role(get_settings('default_role')); 66 } 67 68 if ( $update ) 69 do_action('profile_update', $user_id); 70 else 71 do_action('user_register', $user_id); 72 73 return $user_id; 74 } 75 76 function wp_update_user($userdata) { 77 global $wpdb; 78 79 $ID = (int) $userdata['ID']; 80 81 // First, get all of the original fields 82 $user = get_userdata($ID); 83 84 // Escape data pulled from DB. 85 $user = add_magic_quotes(get_object_vars($user)); 86 87 // If password is changing, hash it now. 88 if ( ! empty($userdata['user_pass']) ) { 89 $plaintext_pass = $userdata['user_pass']; 90 $userdata['user_pass'] = md5($userdata['user_pass']); 91 } 92 93 // Merge old and new fields with new fields overwriting old ones. 94 $userdata = array_merge($user, $userdata); 95 $user_id = wp_insert_user($userdata); 96 97 // Update the cookies if the password changed. 98 if ( isset($plaintext_pass) ) { 99 wp_clearcookie(); 100 wp_setcookie($userdata['user_login'], $plaintext_pass); 101 } 31 102 32 103 return $user_id; 33 104 } 34 105 106 function wp_create_user( $username, $password, $email ) { 107 global $wpdb; 108 109 $user_login = $wpdb->escape( $username ); 110 $user_email = $wpdb->escape( $email ); 111 $user_pass = $password; 112 113 $userdata = compact('user_login', 'user_email', 'user_pass'); 114 return wp_insert_user($userdata); 115 } 116 117 118 function create_user( $username, $password, $email ) { 119 return wp_create_user( $username, $password, $email ); 120 } 121 122 35 123 ?> -
trunk/wp-register.php
r2732 r2872 31 31 $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 32 32 33 $password = substr( md5( uniqid( microtime() ) ), 0, 7); 33 if ( 0 == count($errors) ) { 34 $password = substr( md5( uniqid( microtime() ) ), 0, 7); 34 35 35 $user_id = create_user( $user_login, $password, $user_email, 0 ); 36 if ( !$user_id ) { 37 $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')); 36 $user_id = wp_create_user( $user_login, $password, $user_email ); 37 if ( !$user_id ) 38 $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')); 39 else 40 wp_new_user_notification($user_id, $password); 38 41 } 39 40 if(count($errors) == 0) {41 $user = new WP_User($user_id);42 $user->set_role(get_settings('default_role'));43 42 44 do_action('user_register', $user_id); 45 46 47 $stars = ''; 48 for ($i = 0; $i < strlen($pass1); $i = $i + 1) { 49 $stars .= '*'; 50 } 51 52 $message = sprintf(__('Username: %s'), $user_login) . "\r\n"; 53 $message .= sprintf(__('Password: %s'), $password) . "\r\n"; 54 $message .= get_settings('siteurl') . "/wp-login.php\r\n"; 55 56 wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message); 57 58 $message = sprintf(__('New user registration on your blog %s:'), get_settings('blogname')) . "\r\n\r\n"; 59 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 60 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; 61 62 @wp_mail(get_settings('admin_email'), sprintf(__('[%s] New User Registration'), get_settings('blogname')), $message); 63 43 if ( 0 == count($errors) ) { 44 64 45 ?> 65 46 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Note: See TracChangeset
for help on using the changeset viewer.