Title: Sticky Groups missing when using BP_Groups_Group::get function
Last modified: September 21, 2016

---

# Sticky Groups missing when using BP_Groups_Group::get function

 *  [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * (@garrett-eclipse)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/sticky-groups-missing-when-using-bp_groups_groupget-function/)
 * Hello,
 * I noticed with a custom plugin I’d built that my call to get all groups including
   hidden groups using BP_Groups_Group::get function that the sticky groups were
   filtered out but not added back in.
 * My Code to get Groups;
 *     ```
       $bp_groups = BP_Groups_Group::get(
           array(
               'type'          => 'alphabetical',
               'show_hidden'   => true
           )
       );
       ```
   
 * Looking into the code of this plugin it appears the sticky groups are filtered
   using the bp_groups_get_paged_groups_sql filter and then added back in using 
   the groups_get_groups filter. This filter is applied through the groups_get_groups
   function which is an alias of BP_Groups_Group::get
 * So in my case I can switch the function I utilize so that the groups_get_groups
   filter is executed to add back the sticky groups.
 * Is it possible to amend this plugin to support the BP_Groups_Group::get approach?
   I’ve seen it used in several themes and plugins.
 * Thank you

Viewing 1 replies (of 1 total)

 *  Thread Starter [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * (@garrett-eclipse)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/sticky-groups-missing-when-using-bp_groups_groupget-function/#post-8942076)
 * I ran into this issue again and took the time to find a workaround, shared below.
 * To work around this Sticky Groups plugin I had to first get an instance of the
   BP_Sticky_Groups class so I could remove the bp_groups_get_paged_groups_sql and
   groups_get_groups filters then reapply them after doing the BP_Groups_Group::
   get function. See code example;
 *     ```
       $bp_sticky_groups = BP_Sticky_Groups::instance();
       remove_filter( 'bp_groups_get_paged_groups_sql', array( $bp_sticky_groups, 'alter_bp_groups_query'     ), 10, 2 );
       remove_filter( 'groups_get_groups',              array( $bp_sticky_groups, 'prepend_stickies_on_front' ), 10, 2 );
       $vgroups =  BP_Groups_Group::get(array(
       	'type'			=> 'alphabetical',
       	'per_page'		=> -1,
       	'show_hidden'	=> true
       ));
       add_filter( 'bp_groups_get_paged_groups_sql', array( $bp_sticky_groups, 'alter_bp_groups_query'     ), 10, 2 );
       add_filter( 'groups_get_groups',              array( $bp_sticky_groups, 'prepend_stickies_on_front' ), 10, 2 );
       ```
   
 * Hope this helps others,
    Cheers

Viewing 1 replies (of 1 total)

The topic ‘Sticky Groups missing when using BP_Groups_Group::get function’ is closed
to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/bp-sticky-groups_334350.svg)
 * [BP Sticky Groups](https://wordpress.org/plugins/bp-sticky-groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/bp-sticky-groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/bp-sticky-groups/)
 * [Active Topics](https://wordpress.org/support/plugin/bp-sticky-groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bp-sticky-groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bp-sticky-groups/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 1 reply
 * 1 participant
 * Last reply from: [Garrett Hyder](https://wordpress.org/support/users/garrett-eclipse/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/sticky-groups-missing-when-using-bp_groups_groupget-function/#post-8942076)
 * Status: not resolved