Source View: user_register
- Hook: user_register
- WordPress version: 2.8
- File: wp-includes/registration.php
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN
(without highlighting).
Understanding Source Code
The best way to understand what a hook does is to look at where it occurs in the source code.
- Action hooks look like this:
do_action( "hook_name" ) - Filter hooks look like this:
apply_filters( "hook_name", "what_to_filter" ).
Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
Source View
| Line | Code |
|---|---|
| 212 | |
| 213 | if ( isset($role) ) { |
| 214 | $user = new WP_User($user_id); |
| 215 | $user->set_role($role); |
| 216 | } elseif ( !$update ) { |
| 217 | $user = new WP_User($user_id); |
| 218 | $user->set_role(get_option('default_role')); |
| 219 | } |
| 220 | |
| 221 | wp_cache_delete($user_id, 'users'); |
| 222 | wp_cache_delete($user_login, 'userlogins'); |
| 223 | |
| 224 | if ( $update ) |
| 225 | do_action('profile_update', $user_id, $old_user_data); |
| 226 | else |
| 227 | do_action('user_register', $user_id); |
| 228 | |
| 229 | return $user_id; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Update an user in the database. |
| 234 | * |
| 235 | * It is possible to update a user's password by specifying the 'user_pass' |
| 236 | * value in the $userdata parameter array. |
| 237 | * |
| 238 | * If $userdata does not contain an 'ID' key, then a new user will be created |
| 239 | * and the new user's ID will be returned. |
| 240 | * |
| 241 | * If current user's password is being updated, then the cookies will be |
| 242 | * cleared. |