title: Wordpress redirect to profile page after user registration
body: <p>I'm trying to redirect users after successful registration to their profile page but no matter where I put the redirect it doesn't seem to work.</p>
  
  <p>The user is being registered correctly but the redirect isn't happening.</p>
  
  <p>All the code seems to be functioning correctly by outputting the correct error messages when there is something that doesn't validate and also registering the user if the information is valid. The only issue is the redirect.</p>
  
  <p>This is the error I am now receiving: Notice: wpdb::escape is deprecated since version 3.6.0! Use wpdb::prepare() or esc_sql() instead.
  My PHP is:</p>
  
  <pre><code>&lt;?php
          $success = '';
          $error = '';
          global $wpdb, $PasswordHash, $current_user, $user_ID;
  
          if(isset($_POST['task']) &amp;&amp; $_POST['task'] == 'register' ) {
              $password1 = $wpdb-&gt;escape(trim($_POST['password1']));
              $password2 = $wpdb-&gt;escape(trim($_POST['password2']));
              $first_name = $wpdb-&gt;escape(trim($_POST['first_name']));
              $last_name = $wpdb-&gt;escape(trim($_POST['last_name']));
              $email = $wpdb-&gt;escape(trim($_POST['email']));
              $username = $wpdb-&gt;escape(trim($_POST['email']));
  
              if( $email == "" || $password1 == "" || $password2 == "" || $first_name == "" || $last_name == "") {
                  $error = 'Please don\'t leave the required fields.';
              } else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                  $error = 'Invalid email address.';
              } else if(email_exists($email) ) {
                  $error = 'Email already exists.';
              } else if($password1 &lt;&gt; $password2 ){
                  $error = 'Password do not match.';      
              } else {
                  $user_id = wp_insert_user( array ('first_name' =&gt; apply_filters('pre_user_first_name', $first_name), 'last_name' =&gt; apply_filters('pre_user_last_name', $last_name), 'user_pass' =&gt; apply_filters('pre_user_user_pass', $password1), 'user_login' =&gt; apply_filters('pre_user_user_login', $username), 'user_email' =&gt; apply_filters('pre_user_user_email', $email), 'role' =&gt; 'young-person') );
                  if( is_wp_error($user_id) ) {
                      $error = 'Error on user creation.';
                  } else {
                      do_action('user_register', $user_id); 
                      wp_redirect ( home_url("/profile") );
                  }
              }
          } ?&gt;
  </code></pre>
  
  <p>And my HTML is:</p>
  
  <pre><code>&lt;form method="post"&gt;
              &lt;div class="row"&gt;
                  &lt;div class="six"&gt;
                      &lt;p&gt;&lt;label&gt;First Name&lt;/label&gt;
                      &lt;input type="text" value="" name="first_name" id="first_name" /&gt;&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="six"&gt;
                      &lt;p&gt;&lt;label&gt;Last Name&lt;/label&gt;
                      &lt;input type="text" value="" name="last_name" id="last_name" /&gt;&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="six"&gt;
                      &lt;p&gt;&lt;label&gt;Email&lt;/label&gt;
                      &lt;input type="text" value="" name="email" id="email" required /&gt;&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="six"&gt;
                      &lt;p&gt;&lt;label&gt;Password&lt;/label&gt;
                      &lt;input type="password" value="" name="password1" id="password1" /&gt;&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="six"&gt;
                      &lt;p&gt;&lt;label&gt;Repeat password&lt;/label&gt;
                      &lt;input type="password" value="" name="password2" id="password2" /&gt;&lt;/p&gt;
                  &lt;/div&gt;
                 &lt;div class="full"&gt;
                     &lt;div class="alignleft"&gt;&lt;?php if($error!= "") { echo $error; } ?&gt;&lt;/div&gt;
  
  
                      &lt;button type="submit" name="btnregister" class="button" &gt;Submit&lt;/button&gt;
                      &lt;input type="hidden" name="task" value="register" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;  
          &lt;/form&gt;
  </code></pre>
  
  <p>Any help would be massively appreciated.</p>