Changing Group tab display defaults
-
Here’s what I’d like to do, if possible: On the home page for any given Group, instead of the activity stream being the default home page (called “Home”), I would like the Forum to be the default home page and be labeled “Forum” in the tab, with the Group activity stream tab just to the right of the new default “Forum” tab and labeled “Group Activity” in the tab.
Here’s a clearer way to show what I mean:
Current BP default — group Home page in bold:
[Home] [Forum] [Members (4)] [Send Invites]
Change to (this exact order and text):
[Forum] [Group Activity] [Members (4)] [Send Invites]
I want to try this method of navigation because I’ve already disabled forum topic commenting in the group activity stream, and I want to make the focus of each group on the forum — that’s where I want most of the post action, not in the group post area.
How to go about doing this? Thanks.
-
Any ideas on how to do this?
I hacked-up the bp-groups.php file just to see if I could accomplish the above. I got most of what I wanted to do working, but not quite, and I don’t really want to edit any core files.
It would probably require a function, if not a full plugin, to do this right, but those are beyond me. Any solutions to this would be greatly appreciated. Thanks.
@snark I’m trying this now. If you’re not using a child theme, I would create one so you don’t mess with the core BP files.
So far, I’ve done this:
1. Copy the function bp_get_options_nav() from bp-core-templatetags.php into my theme’s /groups/single/home.php file
2. Rename it my_bp_get_options_nav()
3. Call it
Not sure what to do next, but will probably try to:
4. Hard code the echo apply_filters to list Forums first.
I’m trying to accomplish the same thing, any luck?
same issue here.
me2 @r-a-y do you’ve a solution
@ruffrazor @twob @erich73 @snark @3sixty
Here’s how to set the “Forum” tab as the default in groups:
I took Boone’s former code and tweaked it with a little URI trickery! Requires no core hacks and complicated function duplication
Paste the following in /wp-content/plugins/bp-custom.php
http://pastebin.com/j3n17CVe (you’ll probably need to tweak the code for BP subdomain installs!) (updated)If you want to reorder it so the “Forum” tab is displayed first, add this snippet to your theme’s functions.php:
http://pastebin.com/eTNKwgCR@r-a-y thanks for this mate! I can’t see a bp-custom.php file in my wp-content/plugins folder though. Should it be there or do I need to create one?
I think I have made the php file properly and pasted in the code but on my site it just shows the code in the header. I must be doing something wrong.
If you just created the bp-custom.php file, you need open and closing PHP tags.
@r-a-y cheers for that. I’m still totally rubbish at coding anything but it now works a treat!
I’ve got the forum as the default tab now and have it first in the list of tabs. Is there a simple way to rename the Home tab to ‘Group Activity’ ?
Thanks again r-a-y
To rename the “Home” tab, add the following line to the “forum tab displayed first” snippet listed above:
$bp->bp_options_nav = 'Activity';
Thanks @r-a-y! Works like a charm.
So this all worked perfectly (thanks @r-a-y) for me, except for one thing. When a person visits a group they would like to join, they are redirected to the home page. My guess is the home/activity page for each buddypress group contains a piece of code to check if the user is logged in or belongs to the group. If they aren’t they are presented with an error message saying they must join the group. With bp-custom in place, the new forum page, I’m assuming, doesn’t have that check and balance and just redirects them back to the root. Any thoughts on this?
@r-a-y, thanks for this as it works great! To @Robcwright and others interested, I know it’s an old thread but have found this change will make it only do this for public groups or groups where you are a member and private groups will no longer redirect but keep the default setup. I put both in bp-custom.php and that seems to work great with a variety of child themes. If you want any other modifications for other cases I haven’t tried, just mention me in the reply and I’ll take a look when I can.
`
function redirect_to_forum() {
global $bp;
$path = clean_url( $_SERVER );
$path = apply_filters( ‘bp_uri’, $path );
if ( bp_is_group_home() && strpos( $path, $bp->bp_options_nav ) === false ) {
if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == ‘public’) {
bp_core_redirect( $path . $bp->bp_options_nav . ‘/’ );
}
}
}
add_action( ‘wp’, ‘redirect_to_forum’ );function my_bp_groups_forum_first_tab() {
global $bp;
if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == ‘public’) {
$bp->bp_options_nav = ’50’;
$bp->bp_options_nav = ‘Activity’;
}
}
add_action(‘wp’, ‘my_bp_groups_forum_first_tab’);
`What I wanna do is eliminate the home tab completely from groups. I don’t see a need for the group activity.
What code would I need to just eliminate the home tab in the bp custom file?
Thanks so much,
eorThanks @r-a-y v.helpful
Here is a small improvement, because depending on the name of the group e.g. “home group” you could get a false positive here with the previous strpos function
`
<?php
function redirect_to_forum() {
global $bp;$path = clean_url( $_SERVER );
$path = apply_filters( ‘bp_uri’, $path );
if ( bp_is_group_home() && $bp->current_action == $bp->bp_options_nav )
bp_core_redirect( apply_filters( ‘bp_uri’, $bp->bp_options_nav) );
}
add_action( ‘wp’, ‘redirect_to_forum’ );
?>
`I have tried this which is great, but it also means that clicking home always takes you to the forum tab, so now there is no way of seeing the group activity – does anyone know how I can change this?
Thanksso this bit of code from @r-a-y seems to let me see the group activity but redirect to forum as default: https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-group-tab-display-defaults/#post-55449
@r-a-y the code you posted on this thread is not available anymore
https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-group-tab-display-defaults/?topic_page=1&num=15
The links to pastebin code are dead. Please post again.Thanks @netweblogic Marcus – that code worked for me and various others didnt !
Thanks @r-a-y that code worked great!
Just a note, If you changed the group slug [via: define( ‘BP_GROUPS_SLUG’, ‘new_slug’ );] you will need to alter this code where it says ‘groups’ to match.
@Marcus
Thanks very much for this – haven’t tried it yet but am about to.
But what I think is really needed is simply the option for the group admin to choose the default tab – as part of the group settings.
I wil have several groups that will need different defaults. Can your code accommodate that in some way?
Who is up to writing a plug-in to do that? Not me I’m afraid..!
I also agree that Home should be changed to Activity.This function creates an infinite loop if the MOD didn’t enable discussion forums for their group.
Updated code to check for that:
`function redirect_to_forum() {
global $bp;$path = clean_url( $_SERVER );
$path = apply_filters( ‘bp_uri’, $path );
if ( bp_is_group_home() && strpos( $path, $bp->bp_options_nav ) === false ) {
if( $bp->bp_options_nav )
bp_core_redirect( $path . $bp->bp_options_nav . ‘/’ );
}
}
add_action( ‘wp’, ‘redirect_to_forum’ );`Thanks guys for your assistance with the code! It’s really helpful
- The topic ‘Changing Group tab display defaults’ is closed to new replies.