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: https://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');