How to change the redirect_to to redirect to the last viewed page? (2 posts)

  1. theMaxx
    Posted 10 years ago #

    Ok, what I would like to do is redirect users to the page they clicked the Login from. For example, if a user is in the comment of a post, I would like a successful login to bring him back to that particular post, so they can go on and post without having to browse back to the post he was about to comment.

    I currently have my wp-login.php set to

    $redirect_to = get_settings('siteurl') . '/index.php';

    which is better for me then the default

    $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';

    I mainly wish to have level 0 user to be affected.
    I tried searching for how to use the referrer but since I don't know PHP, I couldn't find a way to do it.

  2. hemp
    Posted 10 years ago #

    This behaviour applies to almost all users except level 0s. To have it also for them just comment out the following line in wp-login.php:

    if ( 0 == $user->user_level )
    $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php';

    I think that´s a better solution than always redirecting them to the main page.

Topic Closed

This topic has been closed to new replies.

About this Topic