• I was wondering if anyone knows a good way to change the destination page after a user logs in.

    For example, instead of someone going to their WordPress control panel, they would instead be redirected to a particular page on the blog. In my case, I am trying to redirect users once they log in to a particular category page, but still have them logged in and be able to access their control panel from any page.

    Does anyone know if this has been done before? Any advice on how it could be accomplished?

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Will the category page be dependent at all? or will it be the same regardless of user level? If you open up wp-login.php, around line 165 you will se a redirect_to variable. I believe that sets the global redirect value. If you just want the users who register themselves (likely level 0 unless you promote them to authors) than you could edit line 186 to the category url you want the redirection to point towards.

    Thread Starter packin_ball

    (@packin_ball)

    Thanks so much for your reply amory.

    I guess what would be ideal actually, and this is going to sound strange but stick with me, is that when the user logs in the destination page is https://www.mysite.com/wordpress/username

    So the login page would take the value that’s in the user and password box, verify the values and if they are correct, take the value that’s in the user box and add it to the end of https://www.mysite.com/wordpress/

    What will be there is a category page that just so happens to be the user’s name.

    Does that make sense? Anyone know how this can be done?

    Thanks!

    you would have to create the page manually though for each user. So once they first register and log in they will get a 404 page not found. Let me take a look at it and post some code in about an hour or so when i get back

    Thread Starter packin_ball

    (@packin_ball)

    Yeah, each page would be created manually before they log in. I’m leaning towards a series of ‘if’ statements but I’m still struggling with where to put them and how I would redirect using the value the user has entered into the input box.

    Thanks again for your time.

    I changed one of my WP sites to drop back to the index after logging in… I’ve set up most of the posts with permission levels so once logging in they’re able to see more than when they’re not logged in… There isn’t really any need for them to be in the admin area…

    I want to say it was in the wp-login.php file… I did a search for wp-admin… I think there were four results…. yelp if you need more info…

    Thread Starter packin_ball

    (@packin_ball)

    Any idea on how to make the redirect dynamic? Based on the value the user has put into the login box?

    let me go play with some code

    Line 181: $redirect_to = get_settings('siteurl') . '/category/' . $user_login;

    Thread Starter packin_ball

    (@packin_ball)

    Thanks for your help amory!

    I might be coming back with some more questions but I’ll play around with it for now.

    Actually it looks like that replaces line 186 in version 1.5 (i was testing my 1.6 installation). You might want to take a look at this hack. I don’t know exactly what you are aiming for, but thought I’d post the link anyway.

    Thread Starter packin_ball

    (@packin_ball)

    Yeah, I had seen that. It might be what I’m looking for…still checking it out.

    Anyone have anymore advice?

    I had the same issue, so I had a look at the wp-login.php and fixed the redirect:

    lines 181-186 (approx.)

    do_action(‘wp_authenticate’, array(&$user_login, &$user_pass));

    if ($user_login && $user_pass) {
    $user = get_userdatabylogin($user_login);
    if ( 0 == $user->user_level )
    $redirect_to = get_settings(‘siteurl’) . ‘/wp-admin/profile.php’;

    Try changing line 186 from “/wp-admin/profile.php” to “/index.php” (no quotes of course) and that should work.

    Bear in mind this only works for your blog users, not you as admin.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Destination after User Login’ is closed to new replies.