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