Title: Temporarily remove groups functionality?
Last modified: August 31, 2016

---

# Temporarily remove groups functionality?

 *  Resolved [johnmontfx](https://wordpress.org/support/users/johnmontfx/)
 * (@johnmontfx)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/temporarily-remove-groups-functionality/)
 * Is there a way to temporarily remove the Groups permission filtering from queries
   and then re-enable it? I’m using get_posts() in a function to pull a listing 
   of woocommerce orders and having this code as part of the query takes the query
   from 1.1 seconds to 2.5 — which obviously adds up.
 * I’ve tried wp_reset_query() and wp_reset_postdata() but this didn’t help.
 * The following is the full sql search followed by the search without the groups
   functionality — which takes 1.4 seconds less time.
 * `SELECT wppfx_posts.ID FROM wppfx_posts INNER JOIN wppfx_postmeta ON ( wppfx_posts.
   ID = wppfx_postmeta.post_id ) INNER JOIN wppfx_postmeta AS mt1 ON ( wppfx_posts.
   ID = mt1.post_id ) WHERE 1=1 AND ( ( wppfx_postmeta.meta_key = '_customer_user'
   AND CAST(wppfx_postmeta.meta_value AS CHAR) = '9999' ) AND ( mt1.meta_key = '
   wc_termid' AND CAST(mt1.meta_value AS CHAR) != '0' )) AND wppfx_posts.post_type
   = 'shop_order' AND ((wppfx_posts.post_status = 'wc-completed')) <em>AND wppfx_posts.
   ID IN ( SELECT ID FROM wppfx_posts WHERE ID NOT IN ( SELECT post_id FROM wppfx_postmeta
   WHERE wppfx_postmeta.meta_key = 'groups-groups_read_post' ) UNION ALL SELECT 
   post_id AS ID FROM wppfx_postmeta WHERE wppfx_postmeta.meta_key = 'groups-groups_read_post'
   AND wppfx_postmeta.meta_value IN ('assign_topic_tags', 'edit_replies', 'edit_topics','
   level_0', 'participate', 'publish_replies', 'publish_topics', 'read', 'read_private_forums','
   spectate', 'subscriber') ) </em>GROUP BY wppfx_posts.ID ORDER BY wppfx_posts.
   menu_order, wppfx_posts.post_date DESC LIMIT 0, 1`
 * `SELECT wppfx_posts.ID FROM wppfx_posts INNER JOIN wppfx_postmeta ON ( wppfx_posts.
   ID = wppfx_postmeta.post_id ) INNER JOIN wppfx_postmeta AS mt1 ON ( wppfx_posts.
   ID = mt1.post_id ) WHERE 1=1 AND ( ( wppfx_postmeta.meta_key = '_customer_user'
   AND CAST(wppfx_postmeta.meta_value AS CHAR) = '9999' ) AND ( mt1.meta_key = '
   wc_termid' AND CAST(mt1.meta_value AS CHAR) != '0' )) AND wppfx_posts.post_type
   = 'shop_order' AND ((wppfx_posts.post_status = 'wc-completed')) GROUP BY wppfx_posts.
   ID ORDER BY wppfx_posts.menu_order, wppfx_posts.post_date DESC LIMIT 0, 1`
 * [https://wordpress.org/plugins/groups/](https://wordpress.org/plugins/groups/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [johnmontfx](https://wordpress.org/support/users/johnmontfx/)
 * (@johnmontfx)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/temporarily-remove-groups-functionality/#post-7223238)
 * I think I’ve discovered the appropriate filter, as it works before I make my 
   database searches. Basically I do the following:
 * `remove_filter( 'posts_where', array( 'Groups_Post_Access', 'posts_where' ), 
   10, 2 );`
 * [DO MY STUFF]
 * `add_filter( 'posts_where', array( 'Groups_Post_Access', 'posts_where' ), 10,
   2 );`
 * It seems like it gets added back correctly, but it’s only been about 24 hours
   that I’ve been using this on the actual live server.
 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/temporarily-remove-groups-functionality/#post-7223267)
 * Hi John,
 * Thanks for posting your solution, yes that looks correct.
 * Cheers

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Temporarily remove groups functionality?’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Kento](https://wordpress.org/support/users/proaktion/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/temporarily-remove-groups-functionality/#post-7223267)
 * Status: resolved