How to redirect on previous to previous page in wordpress
php, wordpress
Solution
As mentioned in the docs, you can use: `<?php wp_get_referer() ?>` to get the last URL visited by user, before logout or after login.
Problem
I am a newbie to `wordpress`. I am currently working on registration and login. I have a page restrict url let `http://xyz.com/abc`. Login/registration is required for this url. I need that when a user register or login then it should be redirected on this previous url. In login I have added the following hook : a ``` add_filter('login_redirect', 'redirect_previous_page', 10); function redirect_previous_page(){ global $user; $request = $_SERVER["HTTP_REFERER"]; if ( in_array( $user->roles[0], array( 'administrator') ) ) { return admin_url(); return $redirect_to; } elseif ( in_array( $user->roles[0], array( 'subscriber') ) ) { return $request; return $redirect_to; } } ``` 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