Feature Your Forums And Get Them Noticed!
The forums on our Buddypress sites are the heart and soul of our communities, but how do we get them noticed more by our visitors and how do we keep those visitors up to date with the latest that’s going on?
I’m going to give you 2 VERY SIMPLE tricks that will enhance the visibility of your forums as well as make them quicker and easier to access.
Trick 1 – Make your forums the default ‘Groups’ tab
This trick can be done in 2 minutes and merely requires you to paste the following code into your bp-custom.php file:
function redirect_to_forum() { global $bp; $path = clean_url( $_SERVER['REQUEST_URI'] ); $path = apply_filters( 'bp_uri', $path ); if ( bp_is_group_home() && strpos( $path, $bp->bp_options_nav['groups']['home']['slug'] ) === false ) bp_core_redirect( $path . $bp->bp_options_nav['groups']['forum']['slug'] . '/' ); } add_action( 'wp', 'redirect_to_forum' );
Now when a member of your site clicks on a group, rather than being forwarded to the group’s activity tab, they will hit your forums instead! this stops new members getting confused by the activity stream and thinking that the activity stream is actually a forum! (You may laugh, but it happens!)
Trick 2 – Install Rich’s ‘latest Forum Posts’ Widget
Now this widget is a must have in my opinion. It is actually part of Rich’s ‘Forum Extras’ plugin which comes with heaps of extras for your forums. Be sure to check it out if you really want to add a lot of new functionality to your group forums. The code snippet below adds a new widget that displays the latest forum topics.
Copy this code into your bp-custom.php or functions.php file:
class MY_Latest_Topics_Widget extends WP_Widget { function my_latest_topics_widget() { parent::WP_Widget( false, $name = __( 'Latest Topics', 'buddypress' ) ); //if ( is_active_widget( false, false, $this->id_base ) ) } function widget($args, $instance) { global $bp; //don't care to load on these pages if ( bp_is_register_page() || bp_is_activation_page() || bp_is_user_blogs() ) return; if ( $bp->forums->slug == $bp->current_component ) return; if ( $bp->forums->slug == $bp->current_component && bp_is_directory() ) return; //add in more here if you do not want to display this on certain pages (see bp-core-templatetags for list of built-in checks) extract( $args ); if ( !is_numeric( $instance['forum_latest_limit'] ) ) $instance['forum_latest_limit'] = 10; echo $before_widget; echo $before_title . $widget_name . $after_title; if ( bp_has_forum_topics( 'no_stickies=no&page=false&max='. $instance['forum_latest_limit'] ) ) : ?>
So there you have it! Hopefully your members will find your forums quicker and can now see what the latest chat is about when they are on any page of your site!
Get the conversation going!
Can trick 1 be done via functions.php as well ? I have searched high and low for a bp-custom.php file in my folders but I can’t seem to find it. I know you write that Trick 2 can be done via either the folder, so I was hoping you maybe accidentally forgot to include functions.php in the first trick as an option.
Thanks in advance.
Yes it can! A BP-Custom.php file is something you need to create yourself. read this: http://codex.buddypress.org/extending-buddypress/bp-custom-php/
But you can also put this code in functions.php of your child theme
Thank you kindly!
Regarding trick 2 when is paste the code into my site is the following error.
Parse error: syntax error, unexpected ‘&’ in /home3/jxxxxxxx/public_html/wp-content/themes/genesis-buddy-1.2.1/child-theme/functions.php on line 50
line 50 is
if ( $bp->forums->slug == $bp->current_component )
Looks to me like its something in the code I copied from this post.
Any Ideas?
Already had the widget, but thanks for Trick 1. Loving this site…
Hmm…. Trick 1 didn’t seem to work for me. Where should this bp-custom file be located? In the BP-Default folder(If I’m using that theme of course)?
Cool tricks!
I should note that Trick 1 should probably check to see whether that group has forums enabled before redirecting (as noted in http://buddypress.org/community/groups/bp-group-reviews/forum/topic/the-page-isn%E2%80%99t-redirecting-properly/#post-81663)
Off the top of my head:
if ( empty( $bp->groups->current_group->enable_forum ) )
return;
right at the beginning of the function.
Nice one Boone! I’ll update the trick to make sure it keeps on working on BP sites that have forums disabled
Trick 1 did nothing for me so I obviously missed something.
I created a bp-custom.php file, added the above code and wrapped it in and uploaded to …/buddypress/
Advice?
Hi Aaron,
bp-custom.php needs to go in …/plugins directory, not …/buddypress.
BTW, can anyone clue me in on a way to adapt this redirect for member profiles?
I’ve tried myself but either wind up with extra trailing slashes in the URL, or a blank screen.
Trick 2 created no widget for me. I pasted the code — after fixing the character encoding — into functions.php and then a bp-custom.php file and neither worked.
I just want to mention I am just beginner to blogging and honestly loved you’re web-site. Almost certainly I’m going to bookmark your website . You surely have beneficial articles. Kudos for sharing with us your blog site.
Hi – code #1 above breaks my site.
Trying to go from the Group directory to a group gets a blank page.
Any ideas why?
WPMU 3.0.1 and BP 1.26.
Thanks – DV
However this code which I found in the BP forums works !
function redirect_to_forum() {
global $bp;
$path = clean_url( $_SERVER['REQUEST_URI'] );
$path = apply_filters( ‘bp_uri’, $path );
if ( bp_is_group_home() && $bp->current_action == $bp->bp_options_nav['groups']['home']['slug'] )
bp_core_redirect( apply_filters( ‘bp_uri’, $bp->bp_options_nav['groups']['forum']['link']) );
}
add_action( ‘wp’, ‘redirect_to_forum’ );
I tried trick 1 – and it did not work. I have a function.php in my child theme – tried adding the code there nothing changed – I tried all a file bp-custom.php and placing the code in there – and nothing happened either?
People who listen to music while they’re sleeping, especially at times when they
Neither tricks really work anymore. Dan V’s solution to trick 1 works. The code for trick 2 has had the character encoding all changed by this site, so you need to sort that out first (> should be a greater than symbol, for example). The widget is created, but doesn’t appear correctly. All I can see is “– posted in ” inside the widget… I don’t think it’s supposed to look like that.
Hi, this is a cnmoemt.To delete a cnmoemt, just log in and view the post's cnmoemts. There you will have the option to edit or delete them.
Code needs to be updated for newer veorsin of buddypress and wordpress. Try a veorsin of this:bp_options_nav[$bp->groups->current_group->slug]['home']['slug'] ) === false ) { if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == public’) { bp_core_redirect( $path . forum/’ ); } }}function move_group_activity_tab() { global $bp; if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) { $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['position'] = ’98 ; $bp->bp_options_nav[$bp->groups->current_group->slug]['home']['name'] = Something’; }}add_action( bp_init’, redirect_group_home’ );add_action( bp_init’, move_group_activity_tab’);?>
where I wrote > I meant “& gt ;” (all together). This site’s character filtering shizzle again.
Trick 1 does not work if utilizing the BP Groups Hierarchy plugin. Any ideas on how to just look at the group slug to see if it is “home” since subgroups have “home” slugs as well.