Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change Member activity stream default tab


  • boristheteacher
    Participant

    @boristheteacher

    The current default tab in the Member activity stream is ‘personal’.

    I’d like to change it to ‘friends’ only while viewing your own profile. I’d also like to add the status update box (found on the ‘personal’ tab) to the ‘friends’ tab.

    When viewing other members’ profiles, the current setup is great, viewing their personal tab makes sense.

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

  • Venutius
    Moderator

    @venutius

    Hi, You could try this:

    function bpven_set_member_default_nav() {
     
        if ( ! bp_is_user_profile() && ! bp_is_user_activity() && ! bp_is_user() ) {
            return;
        }
        if ( bp_displayed_user_id() != bp_loggedin_user_id() ){
    	return;
        }
        bp_core_new_nav_default( array(
    	'parent_slug'        => buddypress()->activity->id,
    	 // other "activity" sub_nav slugs : personal favorites friends groups mentions
    	 'subnav_slug'       => 'friends',
    	 'screen_function'   => 'bp_activity_screen_friends'
    		)
        );
    }
    add_action( 'bp_setup_nav', 'bpven_set_member_default_nav', 20 );

    boristheteacher
    Participant

    @boristheteacher

    Hi Venutius,
    Thank you so much for your reply.
    I just added it the the bp-custom file but unfortunately, it didn’t seem to work.
    My profile page returned nothing (just header and footer of the page)


    Venutius
    Moderator

    @venutius

    Ah sorry, there was a typo, I’ve corrected it now


    boristheteacher
    Participant

    @boristheteacher

    Great, thanks.
    But now, the personal tab redirects to friends. It means that there is no way to access the personal tab. As such, there is no “status update” box anymore.
    Thanks again for your time!


    boristheteacher
    Participant

    @boristheteacher

    My dev friend said to say this:
    “When you set bp_core_new_nav_default to friends tab, you are no longer able to access personal tab since it also keep using the default url slug.”

    And this code:

    function add_settings_subnav_tab() {
    
    if ( bp_is_my_profile() ) {
    
    buddypress()->members->nav->edit_nav(array(
    'position' => 9,
    ), 'friends', 'activity');
    
    global $bp;
    bp_core_new_nav_default(array( 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'subnav_slug' => $bp->friends->slug));
    
    } else {
    
    buddypress()->members->nav->edit_nav(array(
    'position' => 10,
    ), 'friends', 'activity');
    }
    }
    
    add_action( 'bp_setup_nav', 'add_settings_subnav_tab', 100 );

    Venutius
    Moderator

    @venutius

    Thanks for that Boris,

    I’ve updated this to fix the persoal issue and also add the what’s new tab to all activity tabs

    function add_settings_subnav_tab() {
    
    if ( bp_is_my_profile() ) {
    
    	$displayed_user_id = bp_displayed_user_id();
    
    	buddypress()->members->nav->edit_nav(array(
    		'position' => 9,
    		), 'friends', 'activity');
    
    	global $bp;
    	bp_core_new_nav_default(array(
    		'parent_slug' => $bp->activity->slug,
    		'screen_function' => 'bp_activity_screen_friends',
    		'subnav_slug' => $bp->friends->slug));
    	bp_core_remove_subnav_item( 'activity', 'just-me' );
    	bp_core_new_subnav_item( array(
    		'name'            => sanitize_text_field( __( 'Personal', 'bp-profile-activity-wall' ) ),
    		'slug'            => 'just-me',
    		'parent_url'      => bp_core_get_user_domain( $displayed_user_id ) . 'activity/',
    		'parent_slug'     => 'activity',
    		'screen_function' => 'bp_activity_screen_my_activity',
    		'position'        => 10
    	) );
    } else {
    
    	buddypress()->members->nav->edit_nav(array(
    		'position' => 10,),
    		'friends', 'activity');
    	}
    }
    
    add_action( 'bp_setup_nav', 'add_settings_subnav_tab', 100 );
    
    function bpven_load_mention_me() {
    	$displayed_user_id = bp_displayed_user_id();
    	$currentpage = $_SERVER['REQUEST_URI'];
    	if ( bp_is_activity_component() && strpos( $currentpage, 'just-me' ) === false ) {
    		$_GET['r'] = bp_activity_get_user_mentionname( $displayed_user_id );	
    		bp_get_template_part( 'activity/post-form' );
    	}	
    	
    }
    
    add_action( 'bp_before_member_body', 'bpven_load_mention_me' );

    boristheteacher
    Participant

    @boristheteacher

    wow, it’s incredible.
    Works perfectly. Thank you so much 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar