WordPress.org

Make WordPress Core

Ticket #12282: redirect-2.patch

File redirect-2.patch, 2.8 KB (added by usermrpapa, 8 years ago)
  • wp-login.php

     
    372372case 'retrievepassword' :
    373373        if ( $http_post ) {
    374374                $errors = retrieve_password();
    375                 if ( !is_wp_error($errors) ) {
    376                         wp_redirect('wp-login.php?checkemail=confirm');
    377                         exit();
    378                 }
     375        if ( !is_wp_error($errors) ) {
     376                if ( isset( $_REQUEST['redirect_to'] ) ) {
     377                        wp_safe_redirect($_REQUEST['redirect_to']);
     378                } else {
     379                        wp_redirect('wp-login.php?checkemail=confirm');
     380                }
     381                exit();
     382        }
    379383        }
    380384
    381385        if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
    382386
     387        if ( isset( $_REQUEST['redirect_to'] ) ) {
     388                $redirect_to = $_REQUEST['redirect_to'];
     389        } else {
     390                $redirect_to = '';
     391        }
     392        $redirect_to = apply_filters('lostpassword_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '');
     393
    383394        do_action('lost_password');
    384395        login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '</p>', $errors);
    385396
     
    394405        </p>
    395406<?php do_action('lostpassword_form'); ?>
    396407        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Get New Password'); ?>" tabindex="100" /></p>
     408        <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
    397409</form>
    398410
    399411<p id="nav">
     
    452464                $user_login = $_POST['user_login'];
    453465                $user_email = $_POST['user_email'];
    454466                $errors = register_new_user($user_login, $user_email);
    455                 if ( !is_wp_error($errors) ) {
    456                         wp_redirect('wp-login.php?checkemail=registered');
    457                         exit();
    458                 }
     467        if ( !is_wp_error($errors) ) {
     468                if ( isset( $_REQUEST['redirect_to'] ) ) {
     469                        wp_safe_redirect($_REQUEST['redirect_to']);
     470                } else {
     471                        wp_redirect('wp-login.php?checkemail=registered');
     472                }
     473                exit();
     474        }
    459475        }
    460476
     477        if ( isset( $_REQUEST['redirect_to'] ) ) {
     478                $redirect_to = $_REQUEST['redirect_to'];
     479        } else {
     480                $redirect_to = '';
     481        }
     482        $redirect_to = apply_filters('registration_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '');
     483
    461484        login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
    462485?>
    463486
     
    474497        <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
    475498        <br class="clear" />
    476499        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p>
     500        <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
    477501</form>
    478502
    479503<p id="nav">