BuddyDev

Search

Move buddypress sub-tab to another tab

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

    Hello,
    my activity tab have five sub-tabs “Personal ,Mentions,Favorites,Friends,Groups” .. i need to do the following:
    – Move the “Personal sub-tab” from activity tab to “Profile tab” .. and removing it from activity tab.
    – Create “all activities” sub-tab and set it as a default landing sub-tab for activity tab .
    – Set the default landing sub-tab for profile tab to “Personal sub-tab” in case it’s my-profile or it’s a friend .. and to “View sub-tab” for non-friends and anyone else.

    The nearest topic for what i’m trying to do is this one https://buddydev.com/support/forums/topic/move-buddypress-tab/page/2/#post-11903
    .. i have tried the last provided code ‘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”>

      <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( ‘— Everything —’, ‘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>

    </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>”;
    }’

    But there’s a problem in it , when i click on any link “single comment, single activity,view conversation” in the moved personal sub-tab ..the page fail to load , the link keep looping then i get an error that’s the page isn’t redirecting properly , and the printed link in the end be like that
    : 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

    Any help will be highly appreciated ,
    Thanks in advance

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

    One more note , the looping redirect doesn’t happen only in the moved personal sub-tab , but also in all activities sub-tabs under the activity tab

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

    any help please?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2489
    Ravi on #12000

    Hello Mohammed,

    Thank you for posting here.

    I looked at this and there was a redirect issue. When We fix the redirect issue and set some other tab as default for activity, the activity directory stops working.
    There is a bug in the BuddyPress core and we will be opening a ticket for the same.
    I or @sbrajesh will link you to the ticket.

    Thank You
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2489
    Ravi on #12001

    Hello Mohammed,

    I have created a ticket on BuddyPress Trac. You can check the following ticket URL:
    https://buddypress.trac.wordpress.org/ticket/7635

    Thanks
    Ravi

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

    Thanks Ravi, i hope anyone could help there

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

    Hello Ravi,
    it seems nobody cares there :\ .. do you have any other suggestion to achieve it .. moving the personal sub-tab to profile tab .. i mean if there’s another approach not related to this bug .. Thanks

You must be logged in to reply to this topic.

This topic is: not resolved