Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 28 total)
  • Nope, I’d start a new thread about it.


    Andrew Tegenkamp
    Participant

    @andrewteg

    I never found a good solution for this. We ended up having 2 main types of groups that we wanted to differentiate between so we were hoping for two big groups with subforums, but just ended up making each its own group.

    We added some metadata to each group (https://codex.buddypress.org/plugindev/how-to-edit-group-meta-tutorial/) and just used that on a custom template (https://webdevstudios.com/2015/06/02/creating-custom-templates-for-buddypress/) and showed things a little differently, but they are all just regular old BP groups in the end.


    Andrew Tegenkamp
    Participant

    @andrewteg

    I cross posted at https://bbpress.org/forums/topic/sub-forums-inside-a-group/ since this is that area where they work with each other, but any guidance even on where to get started to develop this as an option or feature is certainly appreciated.

    Thanks.


    Andrew Tegenkamp
    Participant

    @andrewteg

    I will, but I thought it was a BuddyPress question since I’m asking how to keep a component inside the Group template.


    Andrew Tegenkamp
    Participant

    @andrewteg

    Thanks! Thought I was going crazy 🙂


    Andrew Tegenkamp
    Participant

    @andrewteg

    I’ve found WooCommerce is setting the display name to just the first name. It appears BP uses the display name which makes sense for BP. To change this, you can use this bit of code:

    add_filter('pre_user_display_name','g3_change_display_name');
    function g3_change_display_name($name) {
    	if ( isset( $_POST['billing_first_name'] ) ) $firstname = sanitize_text_field( $_POST['billing_first_name'] );
    	if ( isset( $_POST['billing_last_name'] ) ) $lastname = sanitize_text_field( $_POST['billing_last_name'] );
    	if ($firstname && $lastname) $name = $firstname . ' ' . $lastname;
    	return $name;
    }

    It uses a WP hook so should be good no matter what plugins you have or don’t and follows the logic from http://geektamin.com/blog/533/why-update_user_meta-display_name-doesnt-work-and-how-to-use-pre_user_display_name-instead/ if curious. Without Woo of course, the billing_first_name and billing_last_name would be different.


    Andrew Tegenkamp
    Participant

    @andrewteg

    Thanks Hugo. Looks like it’s http://commonsinabox.org/documentation/plugins/bp-group-announcements and https://github.com/cuny-academic-commons/bp-group-announcements has the code so I’ll definitely start there.


    @Venutius
    , I’ll circle back here if I find anything exciting to share, but may be a month or so.

    Thanks! This works great to create just what I needed. I’ll post some sample code for anyone interested when I have it cleaned up a bit more.

    There is also a free plugin at http://www.buddyboss.com/purchase/buddypress-auto-group-join/ if that helps.

    Thanks, I got it fixed with this code (xprofile field id 2 = Yes) if it helps anyone else out.

    add_filter('bp_before_has_members_parse_args', 'get_custom_user_ids');
    add_filter('bp_get_total_member_count', 'custom_members_count');
    function get_custom_user_ids( $retval ) {
    	global $wpdb;
    	$custom_ids = $wpdb->get_col("SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 2 AND value = 'Yes'"); //print_r($custom_ids);
    	if ( !empty( $custom_ids ) ) $retval['include'] = $custom_ids;
    	return $retval;
    }
    function custom_members_count ( $count ) {
    	$ids = get_custom_user_ids();
    	return count($ids); 
    }
    

    Hopefully I’ll clean it up in a class but my first shot at that didn’t work out, but I’m sure that’s just me 🙂

    Thanks again!

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

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

    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.

    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 https://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 https://bbpress.org/blog/ for more as it’s new as of yesterday as an official release.

    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.

    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?

    @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 https://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

    I forgot to check for just members/groups so here’s the corrected version…

    `
    function sort_alpha_by_default( $qs ) {
    global $bp;
    if (!$qs && ( $bp->current_component == BP_GROUPS_SLUG || $bp->current_component == BP_MEMBERS_SLUG ) )
    $qs = ‘type=alphabetical&action=alphabetical’;
    return $qs;
    }
    add_filter( ‘bp_dtheme_ajax_querystring’, ‘sort_alpha_by_default’ );
    `

    Old thread but good google result… this mod seems to work best for me

    1) add selected to your theme/child theme and also put Alphabetical at the top.
    2) add this function into your theme’s functions.php
    `
    function sort_alpha_by_default( $qs ) {
    return ($qs) ? $qs : ‘type=alphabetical&action=alphabetical’;
    }
    add_filter( ‘bp_dtheme_ajax_querystring’, ‘sort_alpha_by_default’ );
    `

    Thanks for this… still works great! Anyone know of a site with all the functions listed out for easy searching for things like this yet?

    One such thread with some sample code is https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/filtering-out-activity-stream-stuff/ … I found that searching “activity stream filter” FWIW.

    @EvanBerard ~ I hope this helps, but if not, let me know and I’ll see if I can help some more. The code is certainly not ready for prime-time but does give the ability to add profile fields for groups in Buddypress. You have to know your way around the code a little to understand what is going on though. You can see loader.php @ buddypress-group-fields.php @ http://pastebin.com/DfxwhLXU and compare it to my starting point which is the BP Group Extension API in the BP Codex @ https://codex.buddypress.org/developer-docs/group-extension-api/ to see what I’ve done, which isn’t much, but hopefully it helps you a bit! The ZIP is online for now at http://dl.dropbox.com/u/244479/buddypress-group-fields.zip if you want it but probably won’t keep that up there forever so I wanted to include the code as well.

    I don’t know of anything like that at the moment and have poked around a little for it. Just curious, for your application, would it be the same profile fields for each group? Like Facebook groups have Location, Website, etc for each group but it’s the same list for each group I believe. I’ve been messing around with the Group Extension API (https://codex.buddypress.org/developer-docs/group-extension-api/) and have a basic plugin that has a few of these already pre-defined. It is certainly not very dynamic (yet) but if you have a set you need, I could send you that modified to your list, or the code changes from the base API to what I have if you’re interested in coding it yourself. That’s assuming someone else doesn’t come in and show us both a plugin that already does it which would not surprise me either :)

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

Viewing 25 replies - 1 through 25 (of 28 total)
Skip to toolbar