Skip to:
Content
Pages
Categories
Search
Top
Bottom

redirect user login

  • Avatar of Famous
    Famous
    Participant

    @famous

    I have been using this to redirect a user the their profile page, but now I want to redirect them to a specific page on their blog:
    <?php
    `//=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);
    ?>`

    I added this ` bp_loggedin_user_domain` to replace this `bp_loggedin_user_domain` but it ends up redirecting me to the users-blog/wp-admin. Does anyone have any idea how to redirect the /wp-admin to another page?

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of edinchez
    edinchez
    Participant

    @edinchez

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

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

    Avatar of valuser
    valuser
    Participant

    @valuser

    http://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

    http://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

    Avatar of Famous
    Famous
    Participant

    @famous

    @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);
    ?>
    `

    Avatar of valuser
    valuser
    Participant

    @valuser

    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);`

    Avatar of Famous
    Famous
    Participant

    @famous

    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.

    Avatar of valuser
    valuser
    Participant

    @valuser

    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!

    Avatar of Famous
    Famous
    Participant

    @famous

    @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

    Avatar of valuser
    valuser
    Participant

    @valuser

    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.

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.