Skip to:
Content
Pages
Categories
Search
Top
Bottom

redirect to profile page?

Viewing 25 replies - 1 through 25 (of 25 total)
  • @bphelp

    Participant

    @famous
    Redirect from what? It would help if you explained the criteria. Do you want logged in users redirected to their profile?

    @famous

    Participant

    Yes, I want users who login to be redirected to their profile pages.

    @bphelp

    Participant

    You can try this in bp-custom.php or your themes functions.php:

    
    function bphelp_redirect_to_profile_on_login() {
    global $bp;
    if(!is_user_logged_in()) { 
    wp_redirect( get_option('siteurl') . '/profile' );
    }
    }
    add_filter('get_header','bphelp_redirect_to_profile_on_login',1);
    

    Let me know if it works for you!
    If you dont want to try this then use the plugin:
    https://github.com/bphelp/private_community_for_bp
    And change line 27 accordingly in private-community-for-bp.php to the page you want folks redirected too upon login before you activate the plugin.

    @famous

    Participant

    I put it in the child theme functions and created new bp-custom.php file and neither one worked. I think when I put it in functions it just pointed to http://mysite.com/profile
    In other words it did not act dynamically. :/

    @famous

    Participant

    Does anyone happen to know the correct info to put into bp-custom.php. I just want to redirect users to their profile/member page:
    http://mysite.com/members/user12

    Thanks

    @henrywright-1

    Member

    Trying changing

    wp_redirect( get_option('siteurl') . '/profile' );

    to

    wp_redirect( '/members/' . bp_core_get_username( bp_loggedin_user_id() ) );

    @bphelp

    Participant

    @famous
    To redirect to profile add the following code courtesy of @sbrajesh at BuddyDev to your bp-custom.php :

    
    /*Make sure profile is default component*/
    define('BP_DEFAULT_COMPONENT','profile');
    
    /*let us filter where to redirect */
    add_filter("login_redirect","bpdev_redirect_to_profile",10,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*/
     
    }
    

    For logout use the following code also courtesy of @sbrajesh to redirect back to your home url:

    
    add_filter('logout_url',"bpdev_logout_url",100,2);
    function bpdev_logout_url( $logout_url, $redirect) {
    //simply ignore the redirect and set it to the main domain
    //let us check for buddyopress,if yes,let us get the bp root domain right ?
    if(function_exists("bp_core_get_root_domain"))
    $redirect=bp_core_get_root_domain();
    else
    $redirect = get_blog_option( SITE_ID_CURRENT_SITE, 'siteurl' );
    
    $args = array( 'action' => 'logout' );
    if ( !empty($redirect) ) {
    $args['redirect_to'] = $redirect;
    }
    
    $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
    $logout_url = wp_nonce_url( $logout_url, 'log-out' );
    
    return $logout_url;
    }
    

    @famous

    Participant

    Henry –
    Gave yours a try and it didn’t work.

    BP-help –
    Hmmm the redirect to home works, but the first (redirect to profile) one doesn’t.

    @bphelp

    Participant

    It works for me. I tested it myself. Maybe you have some function in your theme, or plugins that is interfering with it. Have you tried basic troubleshooting by deactivating all plugins other than BP and activating twenty twelve theme or bp-default theme?

    @famous

    Participant

    I am using BBpress login widget, could that be the problem?

    @bphelp

    Participant

    @famous
    I have never used that widget but you can always drop the widget in the dashboard to the inactive widget section and then test if that is what is causing the login redirect function to fail.

    @famous

    Participant

    which brings up another point, how am I supposed to add a login with a child theme of twentytwelve?

    @bphelp

    Participant

    @famous
    That is a little strange. Are using mutisite? On a single site BP install the login/logout shows in the sidebar with the Meta Widget. Are you using a full width template? If so you can use this plugin to provide a login in the toolbar which I use with a full page template with WP 3.5.1 and BP 1.7.2 and it works, get it here:
    https://wordpress.org/plugins/admin-bar-login/
    Please provide as much info as you can on your install. If I can’t help, it will help others to help you. Thanks!

    @famous

    Participant

    @bphelp

    So I don’t want to use the meta widget as that just provides links to the login and register pages, which is an extra click that I don’t want users to have to do.

    I am using mu, using 2012 child theme. Really don’t want to use a plugin, got too many as it is. Thought that BP would have some kind of solution for this outta the box? And if I use bbPress the widget shows up default under widgets and seems to work great.

    Thanks

    @hnla

    Participant

    What did you want? BP used to provide a hardcoded sidebar login bp-me function, you can still find that in bp-default and copy it over to your theme, or grab this upgraded & extended version:
    https://github.com/hnla/hnla-bp-sidebar-me.

    @famous

    Participant

    Didn’t want to use those hardcoded ones cause I have an MU installation and too many sites to account for. The bbPress one works great, I just cannot seem to redirect?

    @bphelp

    Participant

    @famous
    Try this just make sure you follow the instructions in the commented code. Place it in bp-custom.php :

    
    /* Redirects to profile upon login, and upon logout redirects to activity page unless changed in line 6 */
    function bp_help_redirect_to_profile(){
     global $bp_unfiltered_uri;
    
     $bphelp_my_home_page = 'activity';  // WARNING: make sure you replace 'activity' in this line to the same thing you set dashboard/settings/reading front page to.
    
     if ( !is_user_logged_in() && ( $bp_unfiltered_uri[0] != $bphelp_my_home_page ) ) 
      bp_core_redirect( get_option('home') );
    
     elseif( is_user_logged_in() && ( $bp_unfiltered_uri[0] == 'activity') )
    	bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/profile' );
    
    }
    	
    add_action( 'wp', 'bp_help_redirect_to_profile', 3 );
    

    @bphelp

    Participant

    @famous
    Try this just make sure you follow the instructions in the commented code. Place it in bp-custom.php :

    
    /* Redirects to profile upon login, and upon logout redirects to activity page unless changed */
    function bp_help_redirect_to_profile(){
     global $bp_unfiltered_uri;
    
     $bphelp_my_front_page = 'activity';  // WARNING: make sure you replace 'activity' in this line to the same thing you set dashboard/settings/reading front page to.
    
     if ( !is_user_logged_in() && ( $bp_unfiltered_uri[0] != $bphelp_my_front_page ) ) 
      bp_core_redirect( get_option('home') );
    
     elseif( is_user_logged_in() && ( $bp_unfiltered_uri[0] == $bphelp_my_front_page ) )
    	bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/profile' );
    
    }
    	
    add_action( 'wp', 'bp_help_redirect_to_profile', 3 );
    

    @bphelp

    Participant

    @famous
    Use the last code because I made a slight change.

    @famous

    Participant

    didn’t work, I get an infinite loop on the homepage. There has got to be an easy solution to redirect wordpress upon login?

    @bphelp

    Participant

    @famous
    Try this out. This definitely works if you follow the instructions:
    BuddyPress Redirect To Profile Trick Using A Landing Page.

    @erling

    Participant

    Hi BP help.
    I’m also missing the old BP login redirect (to user’s profile).
    Wanted to try your fix, but stuck already before trying – I canĀ“t even find a file called bp-custom.php” – where is it?
    (using the theme Custom Community pro 1.17 and BP latest version – on testsite http://test.ishojvolley.dk)

    @erling

    Participant

    vv

    @aces

    Participant

    @sundev

    Participant
Viewing 25 replies - 1 through 25 (of 25 total)
  • The topic ‘redirect to profile page?’ is closed to new replies.
Skip to toolbar