Creating a custom Front Page for your BuddyPress Groups

custom_group_buddypress

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**
elseif ( bp_group_is_visible() && bp_is_active( 'activity' ) ) : ?>

to
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:
if (have_posts()) : while (have_posts()) : the_post(); ?>

the_ID(); ?>">

the_content(); ?>


endwhile?>
else icon confused Creating a custom Front Page for your BuddyPress Groups >

php locate_template( array'groups/single/activity.php' ), true?>
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:

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!

BuddyPress Hosting Guide Looking for quality BuddyPress hosting? We will guide you through all the available hosting options and help you find the best webhost for your next BuddyPress project!

18 Responses to Creating a custom Front Page for your BuddyPress Groups

  1. James November 16, 2010 at 3:27 pm #

    Awesome trick @modemlooper! Thanks.

    Do you think this is a “futureproof” way of making group front pages?

    Reply
  2. modemlooper November 16, 2010 at 5:51 pm #

    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.

    Reply
  3. bowe November 16, 2010 at 10:54 pm #

    I think I’ll start using this on BP-Tricks for my Theme Support groups as well. Really useful Trick!

    Reply
  4. Avi M November 20, 2010 at 1:24 am #

    I think this is a nice! Would it be possible to this with member pages?

    Reply
  5. jukooz November 20, 2010 at 8:42 am #

    I’m also interested if it is possible with member pages.

    Reply
  6. Hilary November 21, 2010 at 10:24 pm #

    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/

    Reply
  7. modemlooper November 22, 2010 at 12:25 am #

    Custom member pages should work.

    Reply
  8. Jim December 12, 2010 at 11:03 pm #

    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.

    Reply
  9. aj martin December 17, 2010 at 7:05 am #

    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.

    Reply
  10. rob January 18, 2011 at 3:00 am #

    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?

    Reply
  11. du hoc singapore March 10, 2011 at 3:07 pm #

    Hi,

    I am using Buddy Press for my site and I want to change my group default home page to something like a blog and my users can post and entry, add some banners, etc.

    Please kindly advise me.

    Thanks

    Reply
  12. Johnny July 16, 2011 at 1:53 pm #

    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'] . ‘/$
    }*/

    Reply
  13. du hoc nuoc nga November 17, 2011 at 3:27 pm #

    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.

    Reply
  14. Jason December 29, 2011 at 4:21 pm #

    Is it possible to do this and show the activity stream?

    I want to show group specific info, but not completely hide the activity stream

    Reply
  15. Chiinook February 20, 2012 at 6:18 am #

    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();

    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.

    Reply
    • Chiinook February 20, 2012 at 6:22 am #

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


      the_title();





      Reply
  16. Chiinook February 20, 2012 at 6:30 am #

    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;

    Reply

Trackbacks/Pingbacks

  1. BuddyPress Tutorial Roundup: 15 Useful Hacks and Customizations - WordPress, Multisite and BuddyPress plugins, themes, news and help – WPMU.org - November 19, 2010

    [...] View Tutorial [...]

Leave a Reply