boonebgorges / buddypress-docs

GNU General Public License v3.0
106 stars 44 forks source link

WP_Query gets tax_query added to it #575

Closed devotoare closed 7 years ago

devotoare commented 7 years ago

Trying to write some code to run on the CRON system and am having problems when using WP_Query to get the documents it is returning no results. Upon debugging the query I found that it is adding a tax_query for the term "bp_docs_access_anyone", which I did not add to the query args.

Additionally, I added suppress_filters >= true to the code and it did not alter the query any.

boonebgorges commented 7 years ago

Upon debugging the query I found that it is adding a tax_query for the term "bp_docs_access_anyone", which I did not add to the query args.

BuddyPress Docs adds this tax_query automatically to any WP_Query that includes bp_doc as one of its post types. It does this in order to enforce visibility restrictions. In your cron tool, or in any situation where you need to script access to Docs items where WP cookie auth will not be used, I recommend the following:

remove_action( 'pre_get_posts', 'bp_docs_general_access_protection', 28 );