• Hello all. I’m having trouble with redirects after login.

    I’m running WP 3.1.1. BuddyPress 1.2.8, and S2Member 3.5.8
    I am also using the Suffusion Theme 3.7.8 and the Suffusion Theme Buddy Press Plugin 1.02

    I am NOT running multisite.

    In the S2 Member options I have NOTHING set for the login redirect page and I have NOTHING set in the login REDIRECT field. So as far as I know, S2 should not be affecting the redirect behavior in any way.

    In the admin bar at the top, the login menu item has a hard coded redirect to the site home page. Fine. I understand that and can deal with it.

    But when I use the meta widget, the login link that invokes wp-login.php has no redirect parameter.

    BUT

    When I follow that link to the login form and view page source, I can see a hidden field redirect_to field:
    <input type=”hidden” name=”redirect_to” value=”https://www.doityourselfcitizen.com/wp-admin/&#8221; />

    This sucks because I don’t want logged in users to go to the dashboard.

    I am using two S2 member levels. Member Level 1 is effectively a subscriber role. It only has the read capability. When I login with an account at this level, it appears that the the user is redirected to their author page. Actually I have a redirect plugin to map all URLs in /author/ space to the corresponding BuddyPress Profile page and that’s where the user ends up. Yay, that’s exactly what I want.

    But when I log in using an account that is at the S2Member Level 2, which has the same capabilities as author (e.g. edit_posts, etc), the user ends up at the wp-admin dashboard.

    I was trying to puzzle through the wp-login.php and I couldn’t follow it exactly. (I’m new to the world of PHP and WP programming). But I could see tests for the edit_post capability in some code that was messing with a $redirect_to variable.

    One last bit of information. All of the above behavior was observed with NOTHING being set in the S2Member Login Welcome page fields in the General Options page. I have experimented both with setting the login redirect and the login welcome page there and I have never been able to create a scenario where those settings were used. As far as I can tell, S2Member is totally cut out of the loop. Based on my reading of some S2Member forum posts, those settings don’t take effect unless there is NO redirect_to form field. But I can’t create any scenario where there is no hidden redirect_to form field in my current set up.

    My ultimate goal, is for the user to _always_ be directed to their BuddyPress Profile field when he/she logs in. Eventually I want to totally get rid of the admin bar and I want the end users at both levels to never see the WP Dashboard. (I’ll use the ucanpost plugin instead to let users at level 2 write posts. )

    The only thing I know to do at this point is to make sure all login links specify a redirect_to parameter. I could do that. But I could only send folks to a static page because you have to know the page at the time the link is generated and you don’t know who’s logging in at that point so you can’t put the username in the redirect_to URL.

    Any guidance or suggestions on things to check would be greatly appreciated.

    Thanks,
    Calvin

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Calvin Powers

    (@cspowers)

    Update:

    Hmmm, I have a test site which has only wp and bp installed, and when i go directly to the wp-login.php login form, the redirect_to field is set to “” which makes a LOT more sense.

    So the question now becomes, who’s setting the redirect_to to be wp-admin on my main site.

    First culprit is Suffusion since I don’t have suffusion on my test site. Off to their forums to ask…… stay tuned……

    Thread Starter Calvin Powers

    (@cspowers)

    Update: I posted this problem over at the Suffusion forum and they say that suffusion isn’t the culprit. So still can’t figure out who’s introducing the redirect to wp-admin in my login form. Gonna ask in the S2Member forum next.

    Thread Starter Calvin Powers

    (@cspowers)

    S2Member forum also says they do not override redirect_to unless there’s no redirect in form.

    I have deactivated all plugins and reverted to the twentyTen theme and see some interesting results.

    for my www domain, which is installed at the top directory of the public_html directory, I continue to see the login form having the redirect_to hidden form field wp-admin redirect as a hidden form field set to the address of the wp-admin page.

    But for my test subdomain, which I have installed in a /test subdirectory, the login form has a redirect_to variable set to “” in the form field.

    I have no idea why this is. Ideally I would uninstall, delete everything and reinstall to see if it’s truly just the location of the install that makes the difference. But I don’t have time to test out that theory.

    For now I’m just going to assume that I have to hard-code the redirect_url on all URLs to the login form. Otherwise the user will be redirected to a page they don’t have access to.

    This might be easy for you to resolve. If you look at the core WP code, you will notice that redirect_to is set to the admin_url in case one is not specified. Since you want to override that, you can try using the login_redirect filter hook. The core code has:

    $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);

    So if you add some code to your child theme to force a different URL you should be fine. The $user variable above will tell you which user is being logged in, so you can pick that user’s profile.

    Hello Sayontan, I too am new to WP and am trying to work through these redirects. Can you be more specific about where the filter hook is placed and how to locate the setting for “redirect_to”?

    I am having this exact problem with those plugins as well (BP, Suffusion, S2Member) and through testing determined it was BuddyPress handling the redirect issue.

    I had originally set up a “Member Home” section that S2Member used to redirect to but once I installed BuddyPress it no longer worked.

    I tried to set up some custom code in bp-custom.php from https://buddydev.com/buddypress/buddypress-trick-redirect-users-to-their-profile-on-login/ just to see if I can redirect anywhere but it did not work.
    <?php
    /*let us filter where to redirect */

    add_filter(“login_redirect”,”bpdev_redirect_to_profile”,100,3);

    function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
    {
    if(empty($redirect_to_calculated))
    $redirect_to_calculated=admin_url();

    /*if the user is not site admin,redirect to his/her profile*/
    if(!is_site_admin($user->user_login))
    return bp_core_get_user_domain($user->ID );
    else
    return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/
    }
    ?>

    Hoping for one last shot, otherwise it seems I may have to try: https://www.thinkinginwordpress.com/2009/12/tweak-your-buddypress-login-to-redirect-to-the-page-user-was-viewing-while-login/
    If I did this, would I just edit wp-login.php?

    Thanks

    Hello.

    I have a similar problem. After disabling Theme My Login, all s2member redirect returns 404 error. IT seems like there’s an additional %2F, %3F etc at the links:

    https://www.harianmalaysia.my/%2F%3Fpage_id%3D0

    I’m really messed up with this since it is a running site.

    My code for logout is this:

    <a href="<?php echo wp_logout_url(urlencode($_SERVER['REQUEST_URI'])); ?>">Log Keluar</a><br />

    THANKS FOR ANY HELP!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘BP Suffusion S2Member = Login Redirect Madness’ is closed to new replies.