• I’ve setup WP1.5 and am in the process of setting up my own templates for it. However, I’m trying to figure out how to make it so that after a user logs in, they aren’t automatically redirected to the profile page, but instead are taken to the main page (in reality the site should take them to the page they were on when they clicked login). After looking through the forums here a bit and googling, I’ve found a few different solutions but nothing seems to be working. I’ve also been digging through the wp-login.php file itself and whenever I make changes I seem to end up breaking the login rather than changing the redirect. Is there a simpler way to do this? If so, why isn’t it an option in the administrative control panel?

    Thanks,

    Mark

Viewing 11 replies - 16 through 26 (of 26 total)
  • ah, for wordpress 2.0 this will only work if you’ve added user_levels (through a role manager)

    if you just want to send subscribers and such straight in, use

    if (!current_user_can(‘edit_posts’)){

    instead.

    I am unclear as to what the procedure is on WP 2.0. I have the same problem with new users (subscriber level) being re-directed to the dashboard/user-profile page when I’d like them to be sent back to the main blog page.

    Is there still no login redirect for WP version 2.0.3? If any one knows how to send users that sign in to blog instead of update profile screen please let me know.

    What would be nice and versatile is to have WP “remember” the users last page and redirect there when you login. The hacks would have to consist of:

    1. When user clicks on “logout”, record the url of the “current” page, preferably in the database.
    2. When user logs in, get the url from the database and redirect there.

    A new column in the “users” table would be needed to record the last url.

    Heres what i came up with…

    In wp-login.php on line 172 (WP 2.0.4), change:

    $redirect_to = ‘wp-admin/’;
    to
    $redirect_to = ‘YOUR BLOG INDEX’;

    line 196

    $redirect_to == ‘wp-admin/’
    to
    $redirect_to == ‘YOUR BLOG INDEX’

    and on line 197

    $redirect_to = get_settings(‘siteurl’) . ‘/wp-admin/profile.php’;
    to
    $redirect_to = get_settings(‘YOUR BLOG INDEX’) . ‘ ‘;

    hope that helps.

    https://www.brokenmachines.net to see it in action.

    could someone explain what exactly you replace YOUR BLOG INDEX with? An example if you will as I’m not sure what my blog index would be. Also can anyone else confirm this works?

    Thanks in advance

    coldfusion055, while trying to be helpful, doesn’t know what they’re doing, so I wouldn’t listen to them if I were you.

    Wherever $redirect_to is manually defined, just change that to something else, like this:

    if ( !isset( $_REQUEST['redirect_to'] ) )
    $redirect_to = 'https://yoursite.com/';
    else
    $redirect_to = $_REQUEST['redirect_to'];

    This seems to work as well:

    I added a line in the file wp-login.php just beneath line 5:

    line 5: $error = '';
    line 6: if (!isset($_REQUEST['redirect_to']) ) $_REQUEST['redirect_to'] = get_settings('siteurl'); \to redirect back to main site.

    This redirects everyone back to the main page afer login or logout.

    Greets,

    Xabbu

    Keep in mind that this type of core hack has to be redone whenever wp is upgraded….

    For what it’s worth, here is a plugin I wrote a while back to do this, I took the idea from another plugin I was playing with but couldn’t get to work (Weasel’s Login Redirect /TextChange https://www.tehblitz.org/?page_id=433).

    $cat login-stayput.php

    <?php
    /*
    Plugin Name: Login Stayput
    Plugin URI:
    Description: Sets redirect_to on wp_loginout function to keep users on the same page. Inspired from Weasel's Login Redirect / Textchange
    Author: Justin S. Peavey
    Version: 0.5
    Author URI: https://www.peavey.org
    */
    function jsp_loginredirect($link) {
    // Add redirect_to argument
    $from = $_SERVER['REQUEST_URI'];
    if (substr_count($link,'?') > 0) {
    $link = str_replace('">','&redirect_to='.$from.'">',$link);
    } else {
    $link = str_replace('">','?redirect_to='.$from.'">',$link);
    }
    return $link;
    }
    add_filter('loginout','jsp_loginredirect');
    ?>

    jpeavey, when I install and activate this in WP 2.0.6 I get a rambling error message about header info, ditto when it is executed on logging in, any ideas?

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘change login redirect’ is closed to new replies.