Hi Stiofan,
Thank you for your reply.
I agree my solution was not the best. The correct is to use HTTP header for this, leaving to the site decide if they are going to cache or not the nounce header (since all the WP (PHP) requests should have the nounce header, I don’t see a problem, it’s a standard).
About the reason that my client needed it, is because he wanted to hide some posts based on some specific rule – a rule only used for logged-in users.
My code worked great on these 3 filters:
– geodir_main_query_posts_where
– geodir_filter_widget_listings_where
– geodir_rest_markers_query_where
But no on the geodir_rest_posts_clauses_where filter because there I can’t see which user is logged in.
If I can suggest something, would be to add the header on this Ajax request. You would keep the WordPress standards and the request would behave like all the other PHP requests, leaving the cache system to decide if the cache should consider or not the nounce header.
I hope all this makes sense.
Thank you so much for your plugin and time.
Best,
Fernando