BuddyDev

Search

[Resolved] Move BuddyPress Tab

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #4948

    Hello Dandy,

    Try the following code and let me know if it works or not

    
    add_action( 'bp_setup_nav', 'buddydev_setup_modified_nav', 20 );
    function buddydev_setup_modified_nav() {
    
    	$bp = buddypress();
    
    	bp_core_remove_subnav_item( buddypress()->activity->id, 'just-me' );
    
    	$bp->bp_options_nav['activity']['mentions']['position'] = 40;
    	$bp->bp_options_nav['activity']['favorites']['position'] = 30;
    
    	if ( bp_is_active('groups') ) {
    		$bp->bp_options_nav['activity']['groups']['position'] = 20;
    	}
    
    	if ( bp_is_active('friends') ) {
    		$bp->bp_options_nav['activity']['friends']['position'] = 10;
    	}
    
    	bp_core_new_nav_item( array(
    			'name'		                => __('Home','buddypress'), //replace with your name
    			'slug'		                => 'home', // slug must be unique
    			'screen_function'	        => 'buddydev_show_activity',
    			'position'                  => 1, // unique
    			'default_subnav_slug'       => false,
    			'show_for_displayed_user'   => true, //Whether the nav item should be visible when viewing a member profile other than your own
    		)
    	);
    
    	bp_core_new_nav_default (
    		array(
    			'parent_slug'       => buddypress()->activity->id,
    			'subnav_slug'       => 'friends',
    			'screen_function'   => 'bp_activity_screen_friends'
    		)
    	);
    
    	if ( bp_displayed_user_domain() ) {
    		$user_domain = bp_displayed_user_domain();
    	} elseif ( bp_loggedin_user_domain() ) {
    		$user_domain = bp_loggedin_user_domain();
    	} else {
    		return;
    	}
    
    	$parent_slug          = bp_get_profile_slug();
    	$slug = trailingslashit( $user_domain . $parent_slug );
    
    	bp_core_new_subnav_item( array(
    		'name'          => __( 'Personal' ),
    		'slug'          => 'just-me',
    		'parent_slug'   => $parent_slug,
    		'parent_url'    => $slug,
    		'position'      => 0,
    		'screen_function' => 'buddydev_show_activity'
    	));
    
    	bp_core_new_nav_default (
    		array(
    			'parent_slug'       => $parent_slug,
    			'subnav_slug'       => 'just-me',
    			'screen_function'   => 'buddydev_show_activity'
    		)
    	);
    
    }
    
    function buddydev_show_activity() {
    	add_action( 'bp_template_content', 'buddydev_render_screen_my_activity' );
    	bp_core_load_template( 'members/single/plugins' );
    }
    
    function buddydev_render_screen_my_activity() {
    
    	?>
    
    	<div class="item-list-tabs no-ajax" id="subnav" role="navigation">
    		<ul>
    
    			<li id="activity-filter-select" class="last">
    				<label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label>
    				<select id="activity-filter-by">
    					<option value="-1"><?php _e( '&mdash; Everything &mdash;', 'buddypress' ); ?></option>
    
    					<?php bp_activity_show_filters(); ?>
    
    					<?php
    
    					/**
    					 * Fires inside the select input for member activity filter options.
    					 *
    					 * @since 1.2.0
    					 */
    					do_action( 'bp_member_activity_filter_options' ); ?>
    
    				</select>
    			</li>
    		</ul>
    	</div><!-- .item-list-tabs -->
    
    	<?php
    	if( is_user_logged_in() && bp_is_my_profile() ) {
    		bp_get_template_part( 'activity/post-form' );
    	}
    	echo "<div class='activity'>";
    	bp_get_template_part( 'activity/activity-loop' );
    	echo "</div>";
    }
    
    

    Thank You
    Ravi

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #4989

    Hi, Ravi

    Sorry to reply late. It works perfectly and exactly what I want. Thank you so much for all updates and helps.

    Thank you.

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #5001

    Hi, Ravi

    Sorry to bother you again. I just found something wrong with this change.

    When I click “Profile” Tab, it did show “Personal” by default. However, when I try to click “View”, it won’t show “Profile view” at all. It still stays in “Personal” which is default.

    Could you check that for me, please?

    Thanks a lot.

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #5024

    Hi, Ravi

    Sorry to grab attention for this topic again. If you have free time, could you spare some time to check this issue for me, please?

    Thank you very much.

  • Keymaster
    (BuddyDev Team)
    Posts: 24496
    Brajesh Singh on #5035

    Hi Dandy,
    I am sorry for the delays. I have notified Ravi and he will be getting back to you today.

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #5047

    Hi Dandy,

    Sorry for the delayed reply. I am looking into it and will let you now.

    Thank You
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #5054

    Hi Dandy,

    I have done some modification in the code. please replace the code with the following and let me know if it works or not.

    
    add_action( 'bp_setup_nav', 'buddydev_setup_modified_nav', 20 );
    function buddydev_setup_modified_nav() {
    
    	$bp = buddypress();
    
    	bp_core_remove_subnav_item( buddypress()->activity->id, 'just-me' );
    
    	$bp->bp_options_nav['activity']['mentions']['position'] = 40;
    	$bp->bp_options_nav['activity']['favorites']['position'] = 30;
    
    	if ( bp_is_active('groups') ) {
    		$bp->bp_options_nav['activity']['groups']['position'] = 20;
    	}
    
    	if ( bp_is_active('friends') ) {
    		$bp->bp_options_nav['activity']['friends']['position'] = 10;
    	}
    
    	bp_core_new_nav_item( array(
    			'name'		                => __('Home','buddypress'), //replace with your name
    			'slug'		                => 'home', // slug must be unique
    			'screen_function'	        => 'buddydev_show_activity',
    			'position'                  => 1, // unique
    			'default_subnav_slug'       => false,
    			'show_for_displayed_user'   => true, //Whether the nav item should be visible when viewing a member profile other than your own
    		)
    	);
    
    	bp_core_new_nav_default (
    		array(
    			'parent_slug'       => buddypress()->activity->id,
    			'subnav_slug'       => 'friends',
    			'screen_function'   => 'bp_activity_screen_friends'
    		)
    	);
    
    	if ( bp_displayed_user_domain() ) {
    		$user_domain = bp_displayed_user_domain();
    	} elseif ( bp_loggedin_user_domain() ) {
    		$user_domain = bp_loggedin_user_domain();
    	} else {
    		return;
    	}
    
    	$parent_slug          = bp_get_profile_slug();
    	$parent_url = trailingslashit( $user_domain . $parent_slug );
    
    	bp_core_new_subnav_item( array(
    		'name'          => __( 'Personal' ),
    		'slug'          => 'just-me',
    		'parent_slug'   => $parent_slug,
    		'parent_url'    => $parent_url,
    		'position'      => 0,
    		'screen_function' => 'buddydev_show_activity'
    	));
    
    	bp_core_remove_subnav_item( 'profile', 'public' );
    
    	if ( ! apply_filters( 'buddydev_hide_profile_personal_tab', false ) ) {
    
    		$sub_nav = array(
    			'name'            => _x( 'View', 'Profile header sub menu', 'buddypress' ),
    			'slug'            => 'public',
    			'parent_url'      => $parent_url,
    			'parent_slug'     => $parent_slug,
    			'screen_function' => 'xprofile_screen_display_profile',
    			'position'        => 0,
    			'link'            => $parent_url.'public',
    		);
    
    		bp_core_new_subnav_item( $sub_nav );
    
    	}
    
    }
    
    add_action( 'bp_xprofile_setup_nav', 'buddydev_setup_default_profile', 5 );
    
    function buddydev_setup_default_profile() {
    	bp_core_new_nav_default( array(
    		'parent_slug'		=> bp_get_profile_slug(),
    		'subnav_slug'		=> 'just-me',
    		'screen_function'	=> 'buddydev_show_activity'
    	) );
    }
    
    function buddydev_show_activity() {
    	add_action( 'bp_template_content', 'buddydev_render_screen_my_activity' );
    	bp_core_load_template( 'members/single/plugins' );
    }
    
    function buddydev_render_screen_my_activity() {
    
    	?>
    
    	<div class="item-list-tabs no-ajax" id="subnav" role="navigation">
    		<ul>
    
    			<li id="activity-filter-select" class="last">
    				<label for="activity-filter-by"><?php _e( 'Show:', 'buddypress' ); ?></label>
    				<select id="activity-filter-by">
    					<option value="-1"><?php _e( '&mdash; Everything &mdash;', 'buddypress' ); ?></option>
    
    					<?php bp_activity_show_filters(); ?>
    
    					<?php
    
    					/**
    					 * Fires inside the select input for member activity filter options.
    					 *
    					 * @since 1.2.0
    					 */
    					do_action( 'bp_member_activity_filter_options' ); ?>
    
    				</select>
    			</li>
    		</ul>
    	</div><!-- .item-list-tabs -->
    
    	<?php
    	if( is_user_logged_in() && bp_is_my_profile() ) {
    		bp_get_template_part( 'activity/post-form' );
    	}
    	echo "<div class='activity'>";
    	bp_get_template_part( 'activity/activity-loop' );
    	echo "</div>";
    }
    
    

    Thank You
    Ravi

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #5062

    Hi, Ravi

    Sorry to reply late. Thanks a million for updating and helping me again about this issue.

    I tried it and it worked perfectly as expected!

    Thanks again.

  • Participant
    Level: Initiated
    Posts: 13
    Mohamed Fahmy on #11903

    Hi Ravi,
    i’m sorry for interfering, i was looking exactly for a similar snipest and find yours finally .. i used it and it moved the personal activity tap to profile as expected .. but i think there’s something missed .. in the moved personal activity page , when i click on a single activity or view conversation links it keeps looping and link doesn’t load , get the “The page isn’t redirecting properly” error .. and the link printed be like this “http://localhost/network/activity/p/242/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/p/#acomment-243&#8221;

    any help with that please?

  • Keymaster
    (BuddyDev Team)
    Posts: 24496
    Brajesh Singh on #11904

    Hi Mohamed,
    Please create a new topic and put a link to this topic as reference. It is a resolved topic and let us keep it that way for the OP.

    Also, please make sure to explain your original requirements(the thing you are trying to accomplish) and the code you have used and what happened.

    Thank you
    Brajesh

The topic ‘ [Resolved] Move BuddyPress Tab’ is closed to new replies.

This topic is: resolved