I'm using Profile Builder to create login page. My login page is: example.com/login/.

I'm trying to redirect to previous page (the page user were before coming to example.com/login/). I have tried this code, but it doesn't work:

add_filter('login_redirect', 'redirect_previous_page', 10, 1);
function redirect_previous_page( $redirect_to ){
global $user;

$request = $_SERVER["HTTP_REFERER"];

if ( in_array( $user->roles[0], array( 'administrator') ) ) {

    return admin_url();

} elseif ( in_array( $user->roles[0], array( 'subscriber') ) ) {

    return $request;

return $redirect_to;

Thank you for any help.

  • Try wp_get_referer(). – Sally CJ Apr 29 '18 at 13:06
  • Unfortunately it did not help. – Ante Medic Apr 29 '18 at 16:05

It seems it is not possible with this version of profile builder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.