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, 1SELECT 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
The topic ‘Temporarily remove groups functionality?’ is closed to new replies.