<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13465] trunk/wp-login.php:
  Add redirect_to and associated filters to registration and password recovery
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13465">13465</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-27 18:21:03 +0000 (Sat, 27 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add redirect_to and associated filters to registration and password recovery. fixes <a href="http://trac.wordpress.org/ticket/12282">#12282</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwploginphp">trunk/wp-login.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwploginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-login.php (13464 => 13465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-login.php        2010-02-27 18:11:45 UTC (rev 13464)
+++ trunk/wp-login.php        2010-02-27 18:21:03 UTC (rev 13465)
</span><span class="lines">@@ -359,11 +359,8 @@
</span><span class="cx">         check_admin_referer('log-out');
</span><span class="cx">         wp_logout();
</span><span class="cx"> 
</span><del>-        $redirect_to = 'wp-login.php?loggedout=true';
-        if ( isset( $_REQUEST['redirect_to'] ) )
-                $redirect_to = $_REQUEST['redirect_to'];
-
-        wp_safe_redirect($redirect_to);
</del><ins>+        $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
+        wp_safe_redirect( $redirect_to );
</ins><span class="cx">         exit();
</span><span class="cx"> 
</span><span class="cx"> break;
</span><span class="lines">@@ -373,12 +370,14 @@
</span><span class="cx">         if ( $http_post ) {
</span><span class="cx">                 $errors = retrieve_password();
</span><span class="cx">                 if ( !is_wp_error($errors) ) {
</span><del>-                        wp_redirect('wp-login.php?checkemail=confirm');
</del><ins>+                        $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
+                        wp_safe_redirect( $redirect_to );
</ins><span class="cx">                         exit();
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( isset($_GET['error']) &amp;&amp; 'invalidkey' == $_GET['error'] ) $errors-&gt;add('invalidkey', __('Sorry, that key does not appear to be valid.'));
</span><ins>+        $redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
</ins><span class="cx"> 
</span><span class="cx">         do_action('lost_password');
</span><span class="cx">         login_header(__('Lost Password'), '&lt;p class=&quot;message&quot;&gt;' . __('Please enter your username or e-mail address. You will receive a new password via e-mail.') . '&lt;/p&gt;', $errors);
</span><span class="lines">@@ -393,6 +392,7 @@
</span><span class="cx">                 &lt;input type=&quot;text&quot; name=&quot;user_login&quot; id=&quot;user_login&quot; class=&quot;input&quot; value=&quot;&lt;?php echo esc_attr($user_login); ?&gt;&quot; size=&quot;20&quot; tabindex=&quot;10&quot; /&gt;&lt;/label&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="cx"> &lt;?php do_action('lostpassword_form'); ?&gt;
</span><ins>+        &lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;&lt;?php echo esc_attr( $redirect_to ); ?&gt;&quot; /&gt;
</ins><span class="cx">         &lt;p class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;wp-submit&quot; id=&quot;wp-submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php esc_attr_e('Get New Password'); ?&gt;&quot; tabindex=&quot;100&quot; /&gt;&lt;/p&gt;
</span><span class="cx"> &lt;/form&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -434,7 +434,7 @@
</span><span class="cx"> 
</span><span class="cx"> case 'register' :
</span><span class="cx">         if ( is_multisite() ) {
</span><del>-                // WPMU doesn't use this
</del><ins>+                // Multisite uses wp-signup.php
</ins><span class="cx">                 wp_redirect( apply_filters( 'wp_signup_location', get_bloginfo('wpurl') . '/wp-signup.php' ) );
</span><span class="cx">                 exit;
</span><span class="cx">         }
</span><span class="lines">@@ -453,11 +453,13 @@
</span><span class="cx">                 $user_email = $_POST['user_email'];
</span><span class="cx">                 $errors = register_new_user($user_login, $user_email);
</span><span class="cx">                 if ( !is_wp_error($errors) ) {
</span><del>-                        wp_redirect('wp-login.php?checkemail=registered');
</del><ins>+                        $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
+                        wp_safe_redirect( $redirect_to );
</ins><span class="cx">                         exit();
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        $redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
</ins><span class="cx">         login_header(__('Registration Form'), '&lt;p class=&quot;message register&quot;&gt;' . __('Register For This Site') . '&lt;/p&gt;', $errors);
</span><span class="cx"> ?&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -473,6 +475,7 @@
</span><span class="cx"> &lt;?php do_action('register_form'); ?&gt;
</span><span class="cx">         &lt;p id=&quot;reg_passmail&quot;&gt;&lt;?php _e('A password will be e-mailed to you.') ?&gt;&lt;/p&gt;
</span><span class="cx">         &lt;br class=&quot;clear&quot; /&gt;
</span><ins>+        &lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;&lt;?php echo esc_attr( $redirect_to ); ?&gt;&quot; /&gt;
</ins><span class="cx">         &lt;p class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;wp-submit&quot; id=&quot;wp-submit&quot; class=&quot;button-primary&quot; value=&quot;&lt;?php esc_attr_e('Register'); ?&gt;&quot; tabindex=&quot;100&quot; /&gt;&lt;/p&gt;
</span><span class="cx"> &lt;/form&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>