Make WordPress Core

Changeset 13465 for trunk/wp-login.php


Ignore:
Timestamp:
02/27/2010 06:21:03 PM (17 years ago)
Author:
nacin
Message:

Add redirect_to and associated filters to registration and password recovery. fixes #12282

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-login.php

    r13427 r13465  
    360360        wp_logout();
    361361
    362         $redirect_to = 'wp-login.php?loggedout=true';
    363         if ( isset( $_REQUEST['redirect_to'] ) )
    364                 $redirect_to = $_REQUEST['redirect_to'];
    365 
    366         wp_safe_redirect($redirect_to);
     362        $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
     363        wp_safe_redirect( $redirect_to );
    367364        exit();
    368365
    … …  
    374371                $errors = retrieve_password();
    375372                if ( !is_wp_error($errors) ) {
    376                         wp_redirect('wp-login.php?checkemail=confirm');
     373                        $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
     374                        wp_safe_redirect( $redirect_to );
    377375                        exit();
    378376                }
    … …  
    380378
    381379        if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
     380        $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
    382381
    383382        do_action('lost_password');
    … …  
    394393        </p>
    395394<?php do_action('lostpassword_form'); ?>
     395        <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
    396396        <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>
    397397</form>
    … …  
    435435case 'register' :
    436436        if ( is_multisite() ) {
    437                 // WPMU doesn't use this
     437                // Multisite uses wp-signup.php
    438438                wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) );
    439439                exit;
    … …  
    454454                $errors = register_new_user($user_login, $user_email);
    455455                if ( !is_wp_error($errors) ) {
    456                         wp_redirect('wp-login.php?checkemail=registered');
     456                        $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
     457                        wp_safe_redirect( $redirect_to );
    457458                        exit();
    458459                }
    459460        }
    460461
     462        $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
    461463        login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
    462464?>
    … …  
    474476        <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
    475477        <br class="clear" />
     478        <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
    476479        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p>
    477480</form>
Note: See TracChangeset for help on using the changeset viewer.