Skip to:
Content
Pages
Categories
Search
Top
Bottom

redirect user login

Viewing 9 replies - 1 through 9 (of 9 total)
  • @edinchez

    Participant

    Not really sure how multisite works, but this plugin here can be configured to work the way you want I think:

    https://wordpress.org/extend/plugins/peters-login-redirect/

    @valuser

    Participant

    https://wordpress.org/extend/plugins/buddypress-login-redirect/ can redirect to 3 different locations after login. 1. Personal Profile / Personal Activity Page 2. Site wide Activity 3. Friends’ Activity

    https://wordpress.org/extend/plugins/login-with-ajax/ this plugin’s settings allows you go to any particular page OR to the current users particular page on login & on logout if you use %USERNAME% — its on the settings page

    @famous

    Participant

    @edinchez & @valuser – it ended up not working the way I thought it would. Is there any way to use my original code with a slight tweak?
    `
    //=Redirect to User’s Profile Page after Login
    function rt_login_redirect($redirect_to, $set_for, $user){
    $redirect_to = bp_loggedin_user_domain($user->id);
    return $redirect_to;
    }
    add_filter(‘login_redirect’, ‘rt_login_redirect’, 20, 3);
    ?>
    `

    @valuser

    Participant

    try this — (replace friends with whatever)

    `function rt_login_redirect($redirect_to, $set_for, $user){
    $redirect_to = bp_core_get_user_domain($user->ID).’/friends/’;
    return $redirect_to;
    }
    add_filter(‘login_redirect’, ‘rt_login_redirect’, 20, 3);`

    @famous

    Participant

    I gave it a try but no dice. It’s odd cause the code will take you through to your profile and also your blog dashboard, so you know there has got to be a way to point to a users blog/page1.php. I’ve searched and searched but cannot find a solution.

    @valuser

    Participant

    Works for me with (as above)

    `bp_core_get_user_domain($user->ID).’/friends/’`

    Does not work with

    `bp_loggedin_user_domain($user->id).’/friends/’`

    Strange!

    @famous

    Participant

    @valuser

    that is strange. I took your chunk of code above and pasted it into the bp-custom.php page in my plugins folder, and this is what I get in my address bar:
    http://localhost/members/user1//friends/

    I get pushed to the member profile instead of their blog

    my specs:
    I am using wordpress MU 3.4 with BP ver 1.5.6. – I place the code in my plugin file bp-custom.php.
    not sure why I would get a different result than you

    @valuser

    Participant

    My apologies.

    i have it in functions.php of the theme – in this case a child of bp-default theme

    yes! that site first went to http://localhost/members/user1//friends/ (2 forward slashes) then resolved to http://localhost/members/user1/friends/ 1 forward slash –correct site

    try
    ` function rt_login_redirect($redirect_to, $set_for, $user){
    $redirect_to = bp_core_get_user_domain($user->ID).’friends/’;
    return $redirect_to;
    }
    add_filter(‘login_redirect’, ‘rt_login_redirect’, 20, 3);`

    forward slash taken away. It now goes there straight away.

    hopefully for you as well.

    @modzirra

    Participant

    So, I’ve been combing these forums for weeks for a very similar problem, and being that this is the closest solution post, I thought I would ask here, extending the support for this problem.

    I would like to redirect users during login in the following manner:

    If logging in from the front page (site, not user): redirect to user profile
    If logging in from anywhere else: redirect to original url (where original url is the url where the login process was initiated)

    Currently I am forced to run the following for backwards compatibility reasons:
    WP: 3.7.3
    php: 5.3.10
    bbPress: 2.5.3
    BuddyPress: 1.9.2 +5 complimentary plugins

    Active Plugins
    45+ with the most relevant being:
    BadgeOS: 1.3.5 +4 complimentary plugins
    Bowe Codes: 2.1
    BP My Home: 2.0
    BP RedirecttoProfileforBuddypress: 1.2
    BP Simple Front End Post: 1.1.4
    BuddyBlog: 1.0.4

    I’ve tried to edit the redirect plugin mentioned often here as well as with no luck.

    Here is a sample of one of my latest attempts (a modification on redirect to profile plugin):

    add_filter("login_redirect","bpme_redirect_to_profile",100,3);
    
    function bpme_redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user ){
    	/* if no redirect was specified,let us think we want the current page */
    	if( empty( $redirect_to_calculated ) )
    		$redirect_to_calculated=$redirect_url_specified;
    	
    	/* if the user is site admin or not and it's the front page,redirect to his/her profile */
    	if( is_super_admin( $user->ID ) && is_front_page() )
    		return bp_core_get_user_domain( $user->ID ) . 'profile/';
    	if( !is_super_admin( $user->ID ) && is_front_page() )
    		return bp_core_get_user_domain( $user->ID ) . 'profile/';
    	else
    		return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/
    
    }

    (I recognize that the admin user check is redundant, that was part of some debugging I was doing)

    I find that every time I try to check for the front page, something happens to interrupt the redirect process. Without a check for front page: Working great! With the check for front page: No Bueno! I’ve been using several debugging plugins and if I understand them correctly, most of the issue has to do with the sidebar login location (it seems to ignore wp_login and login_redirect hooks/filters) and checking for the front page.

    I tried many other plugins and most of the code (with minor adjustments for my needs) that was offered on the forums here, including the Ajax one, but most of our login process is done through the sidebar and they just don’t ever get called or triggered during the sidebar login process.

    I would love some advice on how to adjust what I have and get it working properly.

    Your help is appreciated, thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘redirect user login’ is closed to new replies.
Skip to toolbar