• Resolved Deadpan110

    (@deadpan110)


    BP Group Hierarchy Version: 1.0.4

    Recap:
    BuddyPress Public Groups = Searchable and anyone can join – feed is also viewable.
    BuddyPress Private Groups = Searchable and Members have to request to join – group description is viewable but the activity feed is shown only to Group Members.
    BuddyPress Hidden Groups = Not Searchable and Members are invited only

    Problem:
    A parent Group with children will only show Public Groups (even though Private Groups are visible to all – even logged out users across the BuddyPress enabled site) within the Member Groups tab.

    Suggested Fix:
    In extension.php on line 178, change:

    <?php if($subgroup->status != 'public') continue; ?>

    to:

    <?php if($subgroup->status == 'hidden') continue; ?>

    http://wordpress.org/extend/plugins/bp-group-hierarchy/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Dean

    (@ddean)

    Thanks for catching that! A new release that addresses this issue will be out shortly.

    Please let me know if you find any other issues with the plugin.

    Thread Starter Deadpan110

    (@deadpan110)

    Great work m8!

    I also had to modify the output for group listings.

    do_action( 'bp_directory_groups_actions' )

    I am assuming that this does not work due to the listing not being in the loop (I am still getting used to the workings of BuddyPress).

    The ‘Join Group’, ‘Request to Join’ and all the other buttons and content called within that action are actually for the parent container group.

    I fixed that for my own purposes by replacing the action with:
    echo bp_get_group_join_button( $subgroup )
    Note: bp_group_join_button($subgroup) will not work due to a bug in BuddyPress (See: http://trac.buddypress.org/ticket/3057 )

    I also have a feeling that there is also a bug within:
    echo bp_get_group_type( $subgroup )
    This seems to ignore the $subgroup array.

    I am unsure of the exact procedure for making BuddyPress actually do its loop correctly so I would suggest the following fix:

    Replace all the following:

    <br />
    <div class="action"><br />
    <?php do_action( 'bp_directory_groups_actions' ) ?><br />
    <div class="meta"><br />
    <?php echo bp_get_group_type( $subgroup ) ?> / <?php echo bp_group_hierarchy_get_group_member_count_by_group( $subgroup ) ?><br />
    </div><br />
    </div><br />

    With:

    <br />
    <div class="action"><br />
    <?php do_action('group_hierarchy_directory_groups_actions', $subgroup) ?><br />
    </div><br />

    And then adding it all back in using an add action:


    <?php
    function group_hierarchy_directory_groups_actions($subgroup) {
    ?>
    <div class="action">
    <?php do_action( 'bp_directory_groups_actions' ) ?>
    <div class="meta">
    <?php echo bp_get_group_type( $subgroup ) ?> / <?php echo bp_group_hierarchy_get_group_member_count_by_group( $subgroup ) ?>
    </div>
    </div>
    <?php
    }
    add_action('group_hierarchy_directory_groups_actions', 'group_hierarchy_directory_groups_actions');

    This will not fix the problem and still use the current behaviour BUT will allow plugin users an easier way to change this output if they need to:


    // possibly in a theme (or child theme) functions.php

    function my_custom_directory_groups_actions($subgroup) {
    // My own custom output would go here so there is no need to modify
    //the plugin as changes will be overwritten on an update
    }

    //remove the plugin default action
    remove_action('group_hierarchy_directory_groups_actions', 'group_hierarchy_directory_groups_actions');

    //add my own layout
    add_action('group_hierarchy_directory_groups_actions', 'my_custom_directory_groups_actions');

    Thread Starter Deadpan110

    (@deadpan110)

    Hmm, that did not display as I had intended…
    I hope you can still read it 🙂

    Thread Starter Deadpan110

    (@deadpan110)

    Just had another look into echo bp_get_group_type( $subgroup ).

    The reason I assumed it was not showing the correct group type was because my parent group is set to be a public announce group using the ‘BuddyPress Announce Group’ plugin.

    The group type is modified using a filter by the Announce Plugin and assumes that because the Parent is an Announce group, the child groups also get displayed as ‘Announce ‘ + [group type].

    Maybe this can still be fixed (it does suggest that BuddyPress is not aware of where it is in the loop – but again – I am still getting to grips with BuddyPress).

    Plugin Author David Dean

    (@ddean)

    You are correct that the subgroup display is not within the BuddyPress group “loop.”

    This was a strategic decision to avoid interfering with the parent group, which is in the loop.

    From what you’re saying, it looks like this has caused more trouble than it’s worth. I will take a look at it again to see if there’s a better way to handle it.

    Thread Starter Deadpan110

    (@deadpan110)

    I think I may have over confused the issue and should have started a new topic (soz for that).

    The new method of displaying private (and hidden) groups do work as expected – but even previous to the change, the join group button for each child group was actually for the parent group (from the loop).

    I expect this to be a BuddyPress issue as I am guessing there is no sane way to rewind the loop as can be done for WordPress posts.

    The problem lies within do_action( 'bp_directory_groups_actions' ) as anything using that call to action is unaware of anything other than the parent.

    The best way of addressing this issue is to replace that action with your own filter and add the button from there, this way plugin users can easily remove or modify the filter anyway they choose.


    //do_action( 'bp_directory_groups_actions' );
    do_action( 'bp_hierarchy_directory_groups_actions', $subgroup );

    You can then have a default function to create the button which users can remove or modify if they wish to within their theme.


    function hierarchy_directory_group_button($subgroup) {
    echo bp_get_group_join_button( $subgroup );
    }
    add_action( 'bp_hierarchy_directory_groups_actions', 'hierarchy_directory_group_button');

    Everything else is perfect (the bp_get_group_type( $subgroup ) is broke for me because of another plugin).

    I hope this helps – this plugin IS a fantastic addition to BuddyPress – keep up the good work m8!

    Thread Starter Deadpan110

    (@deadpan110)

    Note to users, Version 1.0.7 now fixes everything I bundled into this Forum Topic.
    The Group Heirachy plugin is now within the loop and even the Announce Group Plugin correctly reports what type of group the child group is set to!
    Many Thanks David!

    *topic now marked as fixed*

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: BP Group Hierarchy] Private Groups do not appear in Parent Member Groups tab’ is closed to new replies.