/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
#CodeDescriptions
1<?php
2/**
3 * User Registration API
4 *
5 * @package WordPress
6 */
7
8/**
9 * Checks whether the given username exists.
10 *
11 * @since 2.0.0
12 *
13 * @param string $username Username.
14 * @return null|int The user's ID on success, and null on failure.
15 */
16function username_exists( $username ) {
17 if ( $user = get_userdatabylogin( $username ) ) {
18 return $user->ID;
19 } else {
20 return null;
21 }
22}
23
24/**
25 * Checks whether the given email exists.
26 *
27 * @since 2.1.0
28 * @uses $wpdb
29 *
30 * @param string $email Email.
31 * @return bool|int The user's ID on success, and false on failure.
32 */
33function email_exists( $email ) {
34 if ( $user = get_user_by_email($email) )
35 return $user->ID;
36
37 return false;
38}
39
40/**
41 * Checks whether an username is valid.
42 *
43 * @since 2.0.1
44 * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
45 *
46 * @param string $username Username.
47 * @return bool Whether username given is valid
48 */
49function validate_username( $username ) {
50 $sanitized = sanitize_user( $username, true );
51 $valid = ( $sanitized == $username );
52 return apply_filters( 'validate_username', $valid, $username );
53}
54
55/**
56 * Insert an user into the database.
57 *
58 * Can update a current user or insert a new user based on whether the user's ID
59 * is present.
60 *
61 * Can be used to update the user's info (see below), set the user's role, and
62 * set the user's preference on whether they want the rich editor on.
63 *
64 * Most of the $userdata array fields have filters associated with the values.
65 * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
66 * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
67 * by the field name. An example using 'description' would have the filter
68 * called, 'pre_user_description' that can be hooked into.
69 *
70 * The $userdata array can contain the following fields:
71 * 'ID' - An integer that will be used for updating an existing user.
72 * 'user_pass' - A string that contains the plain text password for the user.
73 * 'user_login' - A string that contains the user's username for logging in.
74 * 'user_nicename' - A string that contains a nicer looking name for the user.
75 * The default is the user's username.
76 * 'user_url' - A string containing the user's URL for the user's web site.
77 * 'user_email' - A string containing the user's email address.
78 * 'display_name' - A string that will be shown on the site. Defaults to user's
79 * username. It is likely that you will want to change this, for both
80 * appearance and security through obscurity (that is if you don't use and
81 * delete the default 'admin' user).
82 * 'nickname' - The user's nickname, defaults to the user's username.
83 * 'first_name' - The user's first name.
84 * 'last_name' - The user's last name.
85 * 'description' - A string containing content about the user.
86 * 'rich_editing' - A string for whether to enable the rich editor. False
87 * if not empty.
88 * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
89 * 'role' - A string used to set the user's role.
90 * 'jabber' - User's Jabber account.
91 * 'aim' - User's AOL IM account.
92 * 'yim' - User's Yahoo IM account.
93 *
94 * @since 2.0.0
95 * @uses $wpdb WordPress database layer.
96 * @uses apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See note above.
97 * @uses do_action() Calls 'profile_update' hook when updating giving the user's ID
98 * @uses do_action() Calls 'user_register' hook when creating a new user giving the user's ID
99 *
100 * @param array $userdata An array of user data.
101 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not be created.
102 */
103function wp_insert_user($userdata) {
104 global $wpdb;
105
106 extract($userdata, EXTR_SKIP);//Possible Control Flow
107
108 // Are we updating or creating?
109 if ( !empty($ID) ) {
110 $ID = (int) $ID;
111 $update = true;
112 $old_user_data = get_userdata($ID);
113 } else {
114 $update = false;
115 // Hash the password
116 $user_pass = wp_hash_password($user_pass);
117 }
118
119 $user_login = sanitize_user($user_login, true);
120 $user_login = apply_filters('pre_user_login', $user_login);
121
122 //Remove any non-printable chars from the login string to see if we have ended up with an empty username
123 $user_login = trim($user_login);
124
125 if ( empty($user_login) )
126 return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.') );
127
128 if ( !$update && username_exists( $user_login ) )
129 return new WP_Error('existing_user_login', __('This username is already registered.') );
130
131 if ( empty($user_nicename) )
132 $user_nicename = sanitize_title( $user_login );
133 $user_nicename = apply_filters('pre_user_nicename', $user_nicename);
134
135 if ( empty($user_url) )
136 $user_url = '';
137 $user_url = apply_filters('pre_user_url', $user_url);
138
139 if ( empty($user_email) )
140 $user_email = '';
141 $user_email = apply_filters('pre_user_email', $user_email);//Connection Handling
142
143 if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) )
144 return new WP_Error('existing_user_email', __('This email address is already registered.') );
145
146 if ( empty($display_name) )
147 $display_name = $user_login;
148 $display_name = apply_filters('pre_user_display_name', $display_name);
149
150 if ( empty($nickname) )
151 $nickname = $user_login;
152 $nickname = apply_filters('pre_user_nickname', $nickname);
153
154 if ( empty($first_name) )
155 $first_name = '';
156 $first_name = apply_filters('pre_user_first_name', $first_name);
157
158 if ( empty($last_name) )
159 $last_name = '';
160 $last_name = apply_filters('pre_user_last_name', $last_name);
161
162 if ( empty($description) )
163 $description = '';
164 $description = apply_filters('pre_user_description', $description);
165
166 if ( empty($rich_editing) )
167 $rich_editing = 'true';
168
169 if ( empty($comment_shortcuts) )
170 $comment_shortcuts = 'false';
171
172 if ( empty($admin_color) )
173 $admin_color = 'fresh';
174 $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
175
176 if ( empty($use_ssl) )
177 $use_ssl = 0;
178
179 if ( empty($user_registered) )
180 $user_registered = gmdate('Y-m-d H:i:s');
181
182 $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
183
184 if ( $user_nicename_check ) {
185 $suffix = 2;
186 while ($user_nicename_check) {
187 $alt_user_nicename = $user_nicename . "-$suffix";
188 $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
189 $suffix++;
190 }
191 $user_nicename = $alt_user_nicename;
192 }
193
194 $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
195 $data = stripslashes_deep( $data );
196
197 if ( $update ) {
198 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
199 $user_id = (int) $ID;
200 } else {
201 $wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
202 $user_id = (int) $wpdb->insert_id;
203 }
204
205 update_user_meta( $user_id, 'first_name', $first_name);
206 update_user_meta( $user_id, 'last_name', $last_name);
207 update_user_meta( $user_id, 'nickname', $nickname );
208 update_user_meta( $user_id, 'description', $description );
209 update_user_meta( $user_id, 'rich_editing', $rich_editing);
210 update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts);
211 update_user_meta( $user_id, 'admin_color', $admin_color);
212 update_user_meta( $user_id, 'use_ssl', $use_ssl);
213
214 foreach ( _wp_get_user_contactmethods() as $method => $name ) {
215 if ( empty($$method) )
216 $$method = '';
217
218 update_user_meta( $user_id, $method, $$method );
219 }
220
221 if ( isset($role) ) {
222 $user = new WP_User($user_id);
223 $user->set_role($role);
224 } elseif ( !$update ) {
225 $user = new WP_User($user_id);
226 $user->set_role(get_option('default_role'));
227 }
228
229 wp_cache_delete($user_id, 'users');
230 wp_cache_delete($user_login, 'userlogins');
231
232 if ( $update )
233 do_action('profile_update', $user_id, $old_user_data);
234 else
235 do_action('user_register', $user_id);
236
237 return $user_id;
238}
239
240/**
241 * Update an user in the database.
242 *
243 * It is possible to update a user's password by specifying the 'user_pass'
244 * value in the $userdata parameter array.
245 *
246 * If $userdata does not contain an 'ID' key, then a new user will be created
247 * and the new user's ID will be returned.
248 *
249 * If current user's password is being updated, then the cookies will be
250 * cleared.
251 *
252 * @since 2.0.0
253 * @see wp_insert_user() For what fields can be set in $userdata
254 * @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
255 *
256 * @param array $userdata An array of user data.
257 * @return int The updated user's ID.
258 */
259function wp_update_user($userdata) {
260 $ID = (int) $userdata['ID'];
261
262 // First, get all of the original fields
263 $user = get_userdata($ID);
264
265 // Escape data pulled from DB.
266 $user = add_magic_quotes(get_object_vars($user));
267
268 // If password is changing, hash it now.
269 if ( ! empty($userdata['user_pass']) ) {
270 $plaintext_pass = $userdata['user_pass'];
271 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
272 }
273
274 wp_cache_delete($user[ 'user_email' ], 'useremail');
275
276 // Merge old and new fields with new fields overwriting old ones.
277 $userdata = array_merge($user, $userdata);
278 $user_id = wp_insert_user($userdata);
279
280 // Update the cookies if the password changed.
281 $current_user = wp_get_current_user();
282 if ( $current_user->id == $ID ) {
283 if ( isset($plaintext_pass) ) {
284 wp_clear_auth_cookie();
285 wp_set_auth_cookie($ID);
286 }
287 }
288
289 return $user_id;
290}
291
292/**
293 * A simpler way of inserting an user into the database.
294 *
295 * Creates a new user with just the username, password, and email. For a more
296 * detail creation of a user, use wp_insert_user() to specify more infomation.
297 *
298 * @since 2.0.0
299 * @see wp_insert_user() More complete way to create a new user
300 *
301 * @param string $username The user's username.
302 * @param string $password The user's password.
303 * @param string $email The user's email (optional).
304 * @return int The new user's ID.
305 */
306function wp_create_user($username, $password, $email = '') {
307 $user_login = esc_sql( $username );
308 $user_email = esc_sql( $email );
309 $user_pass = $password;
310
311 $userdata = compact('user_login', 'user_email', 'user_pass');
312 return wp_insert_user($userdata);
313}
314
315
316/**
317 * Set up the default contact methods
318 *
319 * @access private
320 * @since
321 *
322 * @return array $user_contactmethods Array of contact methods and their labels.
323 */
324function _wp_get_user_contactmethods() {
325 $user_contactmethods = array(
326 'aim' => __('AIM'),
327 'yim' => __('Yahoo IM'),
328 'jabber' => __('Jabber / Google Talk')
329 );
330 return apply_filters('user_contactmethods',$user_contactmethods);
331}
332
333?>
334
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php