custom_group_buddypress
Coding

Creating a custom Front Page for your BuddyPress Groups

Creating a custom homepage for your group pages is a lot easier then you might think. This Trick will tell you exactly how to create one for one of your groups, that can be easily managed from your WordPress administration menu

Step 1: Download this plugin WP easy post types and activate.

Step 2: Create a post type called Groups

Click the drop down and add new. Add a new post type with the title of a groups slug. Example: say you have a group slug like this groups/bp-tricks, you would then create a group custom type post titled bp-tricks. Add something to the post editor box and hit save.

Important: If you’ve changed the slug of your Groups make sure to use the same name for your Post type!

What we are essentially doing is tricking WP and BP into using the same URL. So by creating a custom post type with the exact URL of a group we can override the front page with a WP page and then use the post editor to create anything.

Step 4: Edit a Template

Go in to your theme folder and open groups/single/home.php

**EDIT LINE 41**
<?php elseif (bp_group_is_visible()&& bp_is_active('activity' )): ?>

to
<?php elseif (!bp_group_is_visible()): ?>


Step 5: Create a new template file

In the same folder groups/single/ create a file called front.php and add the following code and save:
<?php if (have_posts()): while (have_posts()): the_post();?>
<divclass="post"id="post-<?php the_ID();?>">
<divclass="entry">
<?php the_content();?>
</div>
</div>
<?php endwhile;?>
<?php else :?>

<?phplocate_template(array('groups/single/activity.php' ),true )?>
<?php endif;?>

Conclusion

Now when you visit a group it will show the custom post type page instead of the activity stream. There are some issues with the Home tab and i’m going to suggest a core change to make the tabs easier to customize.

In the mean time you could use this code to change the Home tab to activity, add this to bp-custom.php:
<?php
function my_bp_group_overrides(){
global $bp;

$bp->bp_options_nav['groups']['home']['name']= 'Activity';
}
add_action('get_header','my_bp_group_overrides');

?>

You now have a custom group homepage which you can fill with content straight from your WordPress admin panel!

About Bowe Frankema

 Creating a custom Front Page for your BuddyPress Groups Building communities on BuddyPress is something I’m very passionate about. The decision to focus exclusively on BuddyPress projects over the last few years inspired me to share back some of the things I've learned here on BP-Tricks! You can find me on WordCamps & BuddyCamps across the globe and on Twitter! Follow me on Twitter

I'm constantly updating my BuddyPress Hosting Guide and SiteGround and WPEngine
have proven to be a great fit for hosting your BuddyPress community.

Need some help finding the perfect host? Check out my in-depth BuddyPress Hosting guide!

Discussion

19 responses to ‘Creating a custom Front Page for your BuddyPress Groups

  1. Nothing is set in stone. The only core code you change is one line. The rest is a plugin and a custom file that you add. This has worked for me since the BP 1.2. If BP wasn’t so forceful with pushing the activity stream as the front page then you wouldn’t need to change the code.

    I’m going to suggest a core change that allows you to choose a different group front page in admin.

    As it stands you can only remove activity streams site wide but I think it should be on a group by group basis just like forums.

  2. I am busy trying to get the members section to work. I changed the naming to community because of legal reasons on this charity web site I am working on and then members stopped working a day or so later.

    Loved your work around btw, not entirely necessary but someparts I will be using so thanks.

    Any suggestions or ideas as to why the members section would stop working?

    I used the .haccess to change the naming to something different and more inline with the site

    define( ‘BP_FRIENDS_SLUG’, ‘friends’ );
    define( ‘BP_GROUPS_SLUG’, ‘community’ );
    define( ‘BP_MEMBERS_SLUG’, ‘users’ );
    define ( ‘BP_WIRE_SLUG’, ‘noticeboard’ );
    define( ‘BP_MESSAGES_SLUG’, ‘messages’ );
    define( ‘BP_REGISTER_SLUG’, ‘register’ );
    define( ‘BP_ENABLE_USERNAME_COMPATIBILITY_MODE’, true );
    define( ‘BP_SEARCH_SLUG’, ‘search’ );
    define( ‘BP_SETTINGS_SLUG’, ‘users-settings’ );
    define( ‘BP_XPROFILE_SLUG’, ‘users-profile’ );

    BTW if you are using IE6 forget looking as I have blocked that pesky browser.

    http://www.energypractitionersassociation.org/community/all-energy-healing-topics/

  3. On step 5, the smiley face should close with
    : ?>

    I followed the steps, added a page in the Groups easy post tab, but nothing shows up on the Groups pages. Any help? Thanks.

  4. Is there a simple way to make the front page show the main group page ? ( i.e the group listings) same as you get at domainname.com/groups

    Settings/Reading allows you to set a page, posts or your activity stream as the front page but not group listings page.

  5. Hey, tried this work around, but I keep getting a syntax error message on line 1 for the Home tab where the new post should be showing up. Any ideas?

  6. At the moment all my groups automatically send the user to the ‘members’ tab.

    However, I want to send them to the ‘product details’ tab. Which is actually Bp docs renamed.

    If docs is not enable send them to forum. (forum is renamed to discussions)

    If forum is not enabled send them to members.

    If you think you can fix it please update the trac:
    http://tradr.com/groups/report-a-bug/forum/topic/product-groups-lands-on-discussions-tab-and-not-product-details-tab/

    Cheers

    Johnny.

    // product details
    $path = clean_url( $_SERVER[‘REQUEST_URI’] );
    $path = apply_filters( ‘bp_uri’, $path );

    bp_core_redirect( $path . $bp->bp_options_nav[‘groups’][‘docs’][‘slug’] . ‘/’ );
    } else if ( $bp->groups->current_group->enable_forum ) {
    // forums
    $path = clean_url( $_SERVER[‘REQUEST_URI’] );
    $path = apply_filters( ‘bp_uri’, $path );

    bp_core_redirect( $path . $bp->bp_options_nav[‘groups’][‘forum’][‘slug’] . ‘/’ $
    } else {
    // members
    $path = clean_url( $_SERVER[‘REQUEST_URI’] );
    $path = apply_filters( ‘bp_uri’, $path );

    bp_core_redirect( $path . $bp->bp_options_nav[‘groups’][‘members’][‘slug’] . ‘/$
    }*/

  7. We’re a bunch of volunteers and starting a brand new scheme in our community. Your website offered us with valuable information to paintings on. You have done a formidable activity and our whole group will likely be grateful to you.

  8. Using the same logic of “tricking” wp by overlapping group and page slugs, wouldn’t it be possible to create a page hierarchy under the bp auto-generated “Groups” page and pull page content from there?

    I gave it a try and created a set of matching bp groups and wp child-pages (under the “groups” page). Then I inserted the following page query into my empty groups/single/front.php template.


    'page', 'pagename' => bp_the_group() );
    query_posts( $args ); ?>

    the_title();

    <?php edit_post_link( __( '{ Edit }', 'mysite' ), '', '' ); ?>

    This renders the titles and content from ALL pages that match bp-group names … hmmm. Do I need to do something with my query or loop to indicate that 'pagename' => bp_the_group() refers only to THIS group’s name?

    Other than that hitch, this seems to be a good alternative to creating a separate cpt.

    • Sorry, the query looks like this …
      'page', 'pagename' => bp_the_group() );
      query_posts( $args ); ?>


      the_title();



      <?php edit_post_link( __( '{ Edit }', 'woothemes' ), '', '' ); ?>

  9. Well anyway, the point is in the query arguments

    $args = array( ‘post_type’ => ‘page’, ‘pagename’ => bp_the_group() );
    query_posts( $args );
    while ( have_posts() ) : the_post();
    the_title();
    the_content();
    edit_post_link()
    endwhile;

  10. Chiinook, Did you ever find a solution to this? I have the same issue and am looking for a way to pulls content from a specific page that matches the same name. Please advise if you have any insight.

    Thanks!
    Katrina

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>