Description
We have extended the functionality of our WordPress site to allow posts with a status of "future" to be viewable to anonymous users. Making this change allows the posts with the "future" status to be viewable on our website, as well as be available via the JSON API.
This override is not respected by a graphQL query where the "stati" is specified, unless I toggle the "logged in user" in the WordPress, the GraphiQL IDE. Then the correct data is returned.
The WPGraphQL query should respect the current permissions/settings that allow posts to be visible to anonymous users similar to the logic in the WordPress front-end or JSON APIs.
Steps to reproduce
- Create a new post that will be published at a future date
- Take note of the post ID after saving
- Update the functions.php file for the active theme with the following:
function change_future_post_status_permissions() {
global $wp_post_statuses;
$wp_post_statuses['future']->public = true;
}
add_action('init','change_future_post_status_permissions');
- Verify that the post is viewable on the website
- Verify that the post is viewable via the JSON API path: https://wfmt.lndo.site/wp-json/wp/v2/posts/[post_id], and that the "status" attribute has a value of "future".
- Go to the GraphiQL IDE and create the following query:
posts(first: 1000, where: {stati: FUTURE}) {
nodes {
title
postId
}
}
}
Actual results:
"data": {
"posts": {
"nodes": []
}
}
}
Expected results:
"data": {
"posts": {
"nodes": [
{
"postId": 159489,
"status": "future"
}
]
}
}
}
Clicking the "Switch to execute as the logged-in user" button in the GraphiQL IDE and re-running the query produces the expected results.
Additional context
No response
WPGraphQL Version
1.13.7
WordPress Version
6.2
PHP Version
8.4.33
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.
Description
We have extended the functionality of our WordPress site to allow posts with a status of "future" to be viewable to anonymous users. Making this change allows the posts with the "future" status to be viewable on our website, as well as be available via the JSON API.
This override is not respected by a graphQL query where the "stati" is specified, unless I toggle the "logged in user" in the WordPress, the GraphiQL IDE. Then the correct data is returned.
The WPGraphQL query should respect the current permissions/settings that allow posts to be visible to anonymous users similar to the logic in the WordPress front-end or JSON APIs.
Steps to reproduce
Actual results:
Expected results:
Clicking the "Switch to execute as the logged-in user" button in the GraphiQL IDE and re-running the query produces the expected results.
Additional context
No response
WPGraphQL Version
1.13.7
WordPress Version
6.2
PHP Version
8.4.33
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.