WordPress.org

Make WordPress Core

Changeset 11291


Ignore:
Timestamp:
05/12/2009 04:55:06 AM (12 years ago)
Author:
ryan
Message:

Make login more pluggable. Props Denis-de-Bernardy. fixes #9682

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-login.php

    r11204 r11291  
    148148    $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
    149149    $message .= site_url("wp-login.php?action=rp&key=$key", 'login') . "\r\n";
    150 
    151     if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
     150   
     151    $title = sprintf(__('[%s] Password Reset'), get_option('blogname'));
     152   
     153    $title = apply_filters('retrieve_password_title', $title);
     154    $message = apply_filters('retrieve_password_message', $message, $key);
     155   
     156    if ( $message && !wp_mail($user_email, $title, $message) )
    152157        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    153158
     
    175180        return new WP_Error('invalid_key', __('Invalid key'));
    176181
    177     do_action('password_reset', $user);
    178 
    179182    // Generate something random for a password...
    180183    $new_pass = wp_generate_password();
     184   
     185    do_action('password_reset', $user, $new_pass);
     186
    181187    wp_set_password($new_pass, $user->ID);
    182188    update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
     
    185191    $message .= site_url('wp-login.php', 'login') . "\r\n";
    186192
    187     if (  !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
    188         die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
     193    $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
     194
     195    $title = apply_filters('password_reset_title', $title);
     196    $message = apply_filters('password_reset_message', $message, $new_pass);
     197 
     198    if ( $message && !wp_mail($user->user_email, $title, $message) )
     199        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    189200
    190201    wp_password_change_notification($user);
     
    247258//
    248259
    249 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
     260$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
    250261$errors = new WP_Error();
    251262
    252263if ( isset($_GET['key']) )
    253264    $action = 'resetpass';
     265
     266// validate action so as to default to the login screen
     267if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action) )
     268    $action = 'login';
    254269
    255270nocache_headers();
     
    270285if ( SITECOOKIEPATH != COOKIEPATH )
    271286    setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
     287
     288// allow plugins to override the default actions, and to add extra actions if they want
     289do_action('login_form_' . $action);
    272290
    273291$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
Note: See TracChangeset for help on using the changeset viewer.