Skip to:
Content
Pages
Categories
Search
Top
Bottom

Changing Group tab display defaults

  • Avatar of snark
    snark
    Participant

    @snark

    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.

Viewing 25 replies - 26 through 50 (of 62 total)
  • Avatar of Menelik Seth
    Menelik Seth
    Member

    @menelik-seth

    @r-a-y Interesting to note, I’ve just tried the code, and it works. But for some reason, while it works flawlessly on my XAMPP box (Windows Vista), my MAMP box will not load any of the forums or forum posts… It just loads a blank page. I just hope it works on my live server…

    EDIT: Works on my live server. So my MAMP must have something screwy with its settings. Ahh no big, it’s not my main work computer, yet…

    Avatar of Vernon Fowler
    Vernon Fowler
    Participant

    @vernonfowler

    Thanks so much Andrew Tegenkamp. This works exactly how I wanted.

    Robcwright…I added to the code to fix the problem with logged out users or users who aren’t members of private groups being kicked back to the home page when they click on the name of a private group:

    function redirect_to_forum() {
    global $bp;

    $path = clean_url( $_SERVER );

    $path = apply_filters( ‘bp_uri’, $path );

    if ($bp->groups->current_group->user_has_access === true) {

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

    This checks to see if the user has access before redirecting to the forum page as the home page. The function is found in bp_groups.php , line 187.

    Andrew (and others):

    I was referred to this thread to help me figure out how to bypass the group admin page. What I’d like to do instead is have the users go directly to the forum page after the group directory page. I am not clear though how to actually make this happen based on the discussion above though. Would you assist in this modification as well?

    Thank you in advance.

    @andrewteg:

    I was referred to this thread by a moderator to help me figure out how to bypass the group admin page. What I’d like to do instead is have the users go directly to the forum page after clicking the link for a specific group on the group directory page. I am not clear though how to actually make this happen based on the discussion above though. Could you assist in this modification as well?

    Thank you in advance.

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    @jad117, I hope this helps, and please let me know with another mention if not.

    Basically the first step is to create a blank file called bp-custom.php and save it as /wp-content/plugins/bp-custom.php. You can learn more about this file at http://codex.buddypress.org/extending-buddypress/bp-custom-php/ and what it does and all.

    Then, in that file (or in your theme’s functions.php file) you can paste certain bits of PHP code that have become known as hacks or tricks in order to make BuddyPress act a little differently. One such trick is to move around the tabs and redirect people so that group links like http://testbp.org/groups/buddypress-testers-614548248/ would actually redirect to http://testbp.org/groups/buddypress-testers-614548248/forum/ instead of showing http://testbp.org/groups/buddypress-testers-614548248/home/ as it does now.

    The code I gave earlier does this and like myself, some others after me have offered various improvements or changes, so I’d try them each out and see what works best for your setup. You can only have one function of each name at a time or you’ll get an error. You can also visit http://bp-tricks.com/featured/feature-forums-noticed/ for how the author of that post does this “trick” and see some comments there as well, as that is a site devoted to finding just the right trick to get BuddyPress to do exactly what you want!

    I hope that helps, and as I said, if not, write back at me, and I’ll try to answer any questions you have!

    Thanks,
    Andrew

    @andrewteg:

    Thanks so much for your reply and for explaining things to me.

    I think I understand the situation now but the new function’s script is appearing at the top of my webpage above the header. I have also received this message: Warning: Cannot modify header information – headers already sent by (output started at /webroot/s/m/smoke019/primary/www/wp-content/plugins/bp-custom.php:8) in /webroot/s/m/smoke019/primary/www/wp-includes/pluggable.php on line 934.

    Do you know if there’s something that has to get deleted from the second file the warning message mentioned in order to get this conflict to go away?

    Thank you again.

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    Ok, let’s take this in two parts.

    1) If the actual function code is appearing above your header, then make sure you have it inside PHP tags

    Code:
    <?php function{…} ?>

    2) If you are still getting the warning about “Cannot modify header information” I’m going to hope you have a control panel like cPanel or access to your php.ini file. If you have cPanel, check out the “Software/Services” section and then look for “php.ini ezConfig” or something like that. Clicking that brings up a form and you will want to turn on output_buffering and save the form. If you have direct access to your php.ini file (like a localhost setup) then edit php.ini and look for the last instance of output_buffering without a semicolon (; indicates comment in php.ini) in front of it and change it (hopefully) from output_buffering = Off to output_buffering = On. Then you would save the php.ini file and restart Apache.

    If you can’t access either of these, another option to try would be to add this line of php inside the PHP tags you set above:

    Code:
    ini_set(‘output_buffering’, ‘on’);

    If none of this works, post a link if you have it public, or if not, head to http://pastebin.com/ and paste the source of your homepage and I may be able to help some more?

    Avatar of goldmember
    goldmember
    Member

    @goldmember

    @andrewteg, or anyone else that may be able to help. i’ve tried this method, and installed the code verbatim but it’s had no effect on my site.

    here’s a group on my site: http://willowbilliards.com/groups/general-discussion-forum/. You can see that it starts you off on the “Home” tab, not the Forum tab which is what I’d like to do.

    here’s the code in my /wp-content/plugins/bp-custom.php file: http://pastebin.com/pxCWxeie
    here’s the code in my /wp-content/themes/bp-child/functions.php file: http://pastebin.com/Kqyvpe8h (it’s the bottom function).

    please advise what’s wrong. thanks!

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    I’m getting an error on your site because you have my_bp_groups_forum_first_tab delcared in both bp-custom.php and functions.php. Go ahead and remove it from one (probably functions.php for now) because you will get a PHP error since you have the same function name trying to load twice. FYI, the bp-custom.php file is for anything BuddyPress related, where the functions.php file is just for the theme.

    Once it’s working try it when you are not both logged in and on a public group. The if statements in there require that you either be a member of the group or the group be public, so it’s possible it was working but you didn’t see it if you were logged in (probably as the admin) and had not officially joined that group.

    Avatar of goldmember
    goldmember
    Member

    @goldmember

    @andrewteg, thanks but no dice. I only have the bp-custom.php file in there. nothing in functions.php about it. but still no change. i viewed the groups when logged out, and when logged in and the Home tab is still the default.

    please advise. thanks.

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    ok, let’s give this code a shot. I just tried it on a local dev and it worked well.

    Code:
    function redirect_group_home() {
    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 ) {
    /*
    echo "HERE WE GO…";
    echo "<PRE>"; print_r($bp->groups->current_group); echo "</PRE>";
    echo $bp->groups->current_group->status;
    echo $bp->groups->current_group->is_user_member;
    */
    if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == ‘public’) {
    //echo "<PRE>"; print_r($bp->bp_options_nav); echo "</pre>";
    //exit();
    if ($bp->bp_options_nav['groups']['announcements']['slug']) {
    bp_core_redirect( $path . $bp->bp_options_nav['groups']['announcements']['slug'] . ‘/’ );
    } else {
    bp_core_redirect( $path . $bp->bp_options_nav['groups']['forum']['slug'] . ‘/’ );
    }
    //bp_core_redirect( $path . ‘welcome/’ ); //quick hack for some other tab
    }
    }
    }
    function move_group_activity_tab() {
    global $bp;
    if ($bp->groups->current_group->is_user_member || $bp->groups->current_group->status == ‘public’) {
    $bp->bp_options_nav['groups']['home']['position'] = ’98′;
    $bp->bp_options_nav['groups']['admin']['position'] = ’99′;
    $bp->bp_options_nav['groups']['home']['name'] = ‘Activity Log’;
    }
    }
    add_action(‘wp’, ‘redirect_group_home’ );
    add_action(‘bp_init’, ‘move_group_activity_tab’);

    If that does not work for you can you kinda enable debug and comment out the /* and the //echo lines and see if you get anything different?

    On a side note, I noticed you called them forums. Did you know that bbPress is now a plugin at http://wordpress.org/extend/plugins/bbpress/ if you don’t want all the BuddyPress features and just the forum itself? Just an FYI in case that serves ya better. Check out http://bbpress.org/blog/ for more as it’s new as of yesterday as an official release.

    Avatar of goldmember
    goldmember
    Member

    @goldmember

    @andrewteg, I tried the code you provided but nothing new happened. then i got rid of the comment-outs (i think I did it the right way) and I pasted in this code (http://pastebin.com/HY9zwhHg) but that didnt work either.

    i will give that plugin a shot though because all I really want is the forums. Though I do need to be able to occasionally e-mail all the forum members. hopefully it will let me do that.

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    That’s odd ~ are you using 1.5 or on the 1.2 branch? Guess I shoulda asked that before ;)

    Regarding the forums, you may need to disable BuddyPress since the forum plugin bbPress uses the same code as BuddyPress for its forums ~ it’s all bbPress.org and it creates users as WP users so there are plenty of plugins to email all your users FWIW.

    If you do feel comfortable with me FTP’ing into the site, feel free to send me some FTP info and I can take a look. Should only need access to the plugins folder to debug the redirect thing ~ I’m very curiuos why it doesn’t work, but it sounds like BP may be overkill for this project since bbPress is now available so I would understand you heading a different direction too.

    Avatar of goldmember
    goldmember
    Member

    @goldmember

    @andrewteg, I’m using 1.5. Perhaps thats why its not working? If that changes things and there’s a way to do this for 1.5, I’d like to hear it, and I’ll stick with Buddypress. If not, I’ll drop Buddypress and switch to bbPress.

    I’ll send you FTP info for the plugins folder now.

    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    Ok, looks like 1.5 needs this code… should be working on your site too! You can change the 98 to any number really. It stars out at 10, with forum = 40 and members = 60, so just put the number to whatever you want and it will fall in line in the order you want (less than 40 = first, 41-59 = middle, 61+ last). Of course you can change activity log to whatever title you want too.

    Code:
    <?php
    function redirect_group_home() {
    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[$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'] = ‘Activity Log’;
    }
    }
    add_action(‘bp_init’, ‘redirect_group_home’ );
    add_action(‘bp_init’, ‘move_group_activity_tab’);
    ?>
    Avatar of Andrew Tegenkamp
    Andrew Tegenkamp
    Participant

    @andrewteg

    Also use this line in place of the 2 lines with 98 and activity log if you want to just remove the link from the bar (do know the /home/ URL like http://willowbilliards.com/groups/14-1-straight-pool-league/home/ will still work, it just won’t show up in the link list with this line of code:

    Replaces line 15&16 above to remove link:

    Code:
    unset($bp->bp_options_nav[$bp->groups->current_group->slug]['home']);
    Avatar of goldmember
    goldmember
    Member

    @goldmember

    thanks andrew. that’s perfect! you’re the man!

    Avatar of alanchrishughes
    alanchrishughes
    Participant

    @alanchrishughes

    Is there any way of doing this without the redirect? I would rather the forum just work directly out of the groups home page you know?

    /groups/group-title/topic-title

    Thank you so much Andrew that worked brilliantly. I am running WordPress 32.1. and Buddpress 1.5

    Avatar of ewebber
    ewebber
    Participant

    @ewebber

    This is just what I was looking for, moving my live site to 1.5 is getting closer!

    Avatar of Towfiq I.
    Towfiq I.
    Member

    @tislam100

    Anyone know how to add class to the menu item? I tried this:
    `
    function bbg_change_profile_css() {
    global $bp;

    $bp->bp_nav = ‘new_css’;
    }
    add_action( ‘bp_setup_nav’, ‘bbg_change_profile_css’, 999 );`

    But it changes the menu id, but I want to add class to the menu item.

    Avatar of aledmann
    aledmann
    Member

    @aledmann

    I’m really sorry for dragging up an old thread but I just cannot get this to work! I also want to hide the home tab and make the forum tab default in the group pages.

    I’m running WP 3.3.1 and BuddyPress 1.5.4 and have tried every code on here to no avail! Any help would be huuuugely appreciated!!

    Thank you very much! :)

    Avatar of aledmann
    aledmann
    Member

    @aledmann

    Anyone? :s

    Avatar of aledmann
    aledmann
    Member

    @aledmann

    Humpty Bumpty!

Viewing 25 replies - 26 through 50 (of 62 total)

You must be logged in to reply to this topic.