bp_get_options_nav outside the Group?

Is it possible to call bp_get_options_nav() for a specific group ? I need to get the same in-group navigation in every post with a defined post type.

Posts are associated with Groups by slugs and both the group has a meta of post id and the post has a meta of group id (Groups were created from posts), and I’m trying to make the navigation between them seamless.

Related posts

Leave a Reply

1 comment

  1. Read This url:-

    http://www.generalthreat.com/2011/10/creating-a-buddypress-group-home-page/

    https://wordpress.stackexchange.com/questions/58485/adding-navigation-item-page-for-quick-chat-plugin-to-each-of-my-buddypress-group

    Or Try

    Creating a BuddyPress Group Home Page

    enter image description here

    Step One: Create an Activity tab for the activity stream, since we’re displacing it.

    To do this, we’re going to use parts of the Group Extension API to create a new nav item for the group.

    In your theme’s functions.php, add the following:

    function add_activity_tab() {
        global $bp;
    
        if(bp_is_group()) {
            bp_core_new_subnav_item( 
                array( 
                    'name' => 'Activity', 
                    'slug' => 'activity', 
                    'parent_slug' => $bp->groups->current_group->slug, 
                    'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 
                    'position' => 11, 
                    'item_css_id' => 'nav-activity',
                    'screen_function' => create_function('',"bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );"),
                    'user_has_access' => 1
                ) 
            );
    
            if ( bp_is_current_action( 'activity' ) ) {
                add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( 'Activity' ) . '";' ) );
                add_action( 'bp_template_title', create_function( '', 'echo "' . esc_attr( 'Activity' ) . '";' ) );
            }
        }
    }
    
    add_action( 'bp_actions', 'add_activity_tab', 8 );
    

    That adds a tab called ‘Activity’ to every group’s navigation bar, pointing to a page called ‘activity’ within the group. This new activity page is calling the same groups/single/home.php template file as the current home page. That template actually handles routing for ALL group pages, as we’ll see in a minute.

    Step Two: Create a template file for your group Home page

    If you’re going to have a Group home page, you need to control how it’s displayed. To do that, you’ll need a template file in your theme’s groups/single directory. It can be called whatever you’d like, but for this guide, we’re sticking with front.php.

    Create this file and put whatever you want in it. This template will be in the “group loop”, so you can use functions like bp_group_description() to display group info.

    Here’s an example:

    <div class="home-page single-group" role="main">
    <?php if(bp_is_item_admin()) { ?>
        <div class="notice info">
            <p>Welcome to your group home page!<br />
            Click <a href="<?php bp_group_admin_permalink() ?>">Admin</a> above to set the content for this page.</p>
        </div>
    <?php } ?>
    <?php bp_group_description(); ?>
    </div>
    

    Up to now, all we’ve done is create a new Activity tab on the group page that doesn’t even show the activity stream. But this last piece will make everything work:

    Step Three: Edit your theme’s groups/single/home.php template file

    Look for this section in your home.php file:

    elseif ( bp_group_is_visible() && bp_is_active( 'activity' ) ) :
        locate_template( array( 'groups/single/activity.php' ), true );
    
    elseif ( bp_group_is_visible() ) :
       locate_template( array( 'groups/single/members.php' ), true );
    

    This directs a visitor to either the activity stream or the member list, depending on whether activity has been enabled. It’s a catch-all routing section, and it’s where we’ll be adding our group home page.

    Change the lines above to:

    elseif ( bp_group_is_visible() && bp_is_group_activity() ) :
        locate_template( array( 'groups/single/activity.php' ), true );
    
    elseif ( bp_group_is_visible() ) :
        locate_template( array( 'groups/single/front.php' ), true );
    

    This enables the Activity tab AND sends requests for the group home page to your new template! Of course, if you used a name other than front.php, you’ll need to change that line to match the name you chose.

    Update! Step Four – Let BuddyPress JS know how to classify your new activity posts

    Now you can make activity updates, but BuddyPress won’t remember that they came from your group. In order to fix that, we need to relax a check in another file, activity/post-form.php.

    <?php elseif ( bp_is_group_home() ) : ?>
    
        <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
        <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" />
    
    <?php endif; ?>
    

    Without those hidden fields, BuddyPress thinks we’re just posting a personal status update. So let’s expand that to cover our new Activity page:

    <?php elseif ( bp_is_group() ) : ?>
    
        <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
        <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" />
    
    <?php endif; ?>
    

    Now BuddyPress will tie the update to a group no matter where in the group we post it.

    That’s it! Check out your new group home page and enjoy the results your BuddyPress hacking chops. And if you do something really cool with a group Home page, send a link my way!