• Resolved johnmontfx

    (@johnmontfx)


    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://ww.wp.xz.cn/plugins/groups/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter johnmontfx

    (@johnmontfx)

    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

    (@proaktion)

    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.