BuddyDev

Search

[Resolved] Default Tab for Connected Members

Tagged: 

  • Participant
    Level: Initiated
    Posts: 13
    Matthew Ling on #35257

    I still cant seem to get this to work. Should I be replacing $tab with something else? here is what I pasted in php file.

    `/**
    * Modify default tab.
    */
    function buddydev_modify_default_tab( $tab ) {

    if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( ‘friends’ ) ) {
    return $tab;
    }

    // If both are friends set default tab to profile otherwise activity.
    if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
    return ‘friends’;
    }

    return ‘my-survey’;
    }

    add_filter( ‘bp_member_default_component’, ‘buddydev_modify_default_tab’ );

    Sorry for all the confusion, I’m not great at php.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #35260

    Hello Matthew,

    Please remove all the custom code and use above mentioned code. Please copy code from here and then check.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 13
    Matthew Ling on #35263

    Hello, when I use the code as provided and go to the profile of someone I am connected with, I get a 404 error.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #35265
    This reply has been marked as private.
  • Participant
    Level: Initiated
    Posts: 13
    Matthew Ling on #35267
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #35269
    This reply has been marked as private.
  • Participant
    Level: Initiated
    Posts: 13
    Matthew Ling on #35270

    Yes, when I click on a user Im connected with it goes to 404 page, even though the url populates as https://youryous.com/members/username/.

    With the first code provided

    /**
     * Modify default tab.
     */
    function buddydev_modify_default_tab() {
    
    	if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( 'friends' ) ) {
    		return;
    	}
    
            // If both are friends set default tab to profile otherwise activity.
    	if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
    		define( 'BP_DEFAULT_COMPONENT', 'survey' );
    	} else {
    		define( 'BP_DEFAULT_COMPONENT', ‘profile’ );
    	}
    }
    
    add_action( 'bp_setup_globals', 'buddydev_modify_default_tab', 15 );

    It directed to profile correctly but I want it to direct to a specific tab on their profile.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #35271

    Hello Matthew,

    Sorry for the inconvenience. Please provide a demo guest account with some connections so that I can check.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 13
    Matthew Ling on #35272
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1951
    Ravi on #35273

    Hi Matt,
    The code is working correctly. I can see the issue though.

    It seems you have used the User Profile Tabs Creator plugin to modify the availability and visibility of the friends component/tab.

    At the moment, it is not available to the visitors. Since the “friends” tab is only available for the profile owner and not their friends or others, It is causing this error.

    Simple solution is to visit Dashboard->Users->Profile Tabs and edit the tab setting for friends/connections and mark it deactivated

    Please try

You must be logged in to reply to this topic.

This topic is: resolved