Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: password_reset

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.

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
173           exit();
174      }
175
176      $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_activation_key = '$key'");
177      if ( empty( $user ) ) {
178           wp_redirect('wp-login.php?action=lostpassword&error=invalidkey');
179           exit();
180      }
181
182      do_action('password_reset');
183
184      // Generate something random for a password... md5'ing current time with a rand salt
185      $new_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
186      $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$new_pass'), user_activation_key = '' WHERE user_login = '$user->user_login'");
187      wp_cache_delete($user->ID, 'users');
188      wp_cache_delete($user->user_login, 'userlogins');
189      $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
190      $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
191      $message .= get_option('siteurl') . "/wp-login.php\r\n";