BuddyDev

Search

[Resolved] buddypress 'following'

  • Participant
    Level: Initiated
    Posts: 6
    anon.imus on #23827

    Hi,

    I use your plugin called bp redirect to login, Any idea how i might make the redirect go to user’s ‘following’ instead of ‘personal?’

    Thanks a lot,

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #23874

    Hi,
    Thank you for using the plugin.

    Please disable it and use the following code(in plugins/bp-custom.php or your theme’s functions.php)

    
    
    /**
     * Redirect user to their profile if they are not admin.
     *
     * @param string $redirect_to_calculated calculated redirect.
     * @param string $redirect_url_specified specified redirect.
     * @param WP_User $user user.
     *
     * @return string
     */
    function bpdev_custom_redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user ) {
    	if ( ! $user || is_wp_error( $user ) ) {
    		return $redirect_to_calculated;
    	}
    	// If the redirect is not specified, assume it to be dashboard.
    	if ( empty( $redirect_to_calculated ) ) {
    		$redirect_to_calculated = admin_url();
    	}
    	// if the user is not site admin, redirect to his/her profile.
    	if ( function_exists( 'bp_core_get_user_domain' ) && ! is_super_admin( $user->ID ) ) {
    		return bp_core_get_user_domain( $user->ID ) . bp_get_activity_slug() . '/following/';
    	}
    
    	// if site admin or not logged in, do not do anything much.
    	return $redirect_to_calculated;
    }
    
    add_filter( 'login_redirect', 'bpdev_custom_redirect_to_profile', 101, 3 );
    

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    anon.imus on #23876

    Hi brajesh,

    The code showed an ‘x’ error on these lines.

    return bp_core_get_user_domain( $user->ID ) . bp_get_activity_slug() . '/following/';

    As the result, The site broke, Any idea what might be wrong here?

    Regards
    bonga

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #23930

    Hi bonga,

    Please recheck and make sure you copy the code form forum post not from forum notification mail.

    The code is working for me. I tested it again today to confirm it works. I am assuming you are using the 1.3-alpha of BuddyPress follow from github.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 6
    anon.imus on #23951

    Hi brajesh,

    You are spot on, The code works indeed. It seems i didn’t copy it entirely, That’s what broke the site but all is well now. Thank you very much.

    regards
    bonga

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #24030

    You are welcome 🙂

The topic ‘ [Resolved] buddypress 'following'’ is closed to new replies.

This topic is: resolved