title: How to redirect on previous to previous page in wordpress
body: <p>I am a newbie to <code>wordpress</code>. I am currently working on registration and login. I have a page restrict url let <code>http://xyz.com/abc</code>. Login/registration is required for this url. </p>
  
  <p>I need that when a user register or login then it should be redirected on this previous url. </p>
  
  <p>In login I have added the following hook : </p>
  
  <p>a</p>
  
  <pre><code>add_filter('login_redirect', 'redirect_previous_page', 10);
  
  function redirect_previous_page(){
  
      global $user;
      $request = $_SERVER["HTTP_REFERER"];
  
      if ( in_array( $user-&gt;roles[0], array( 'administrator') ) ) {
  
          return admin_url();
          return $redirect_to;
  
      } elseif ( in_array( $user-&gt;roles[0], array( 'subscriber') ) ) {
  
          return $request;
          return $redirect_to;
  
      } 
  
  }
  </code></pre>
  
  <p>It is working for me, but I am not getting how can I redirect on this url after successful registration. I have registration link on the login page</p>