0

I have a plugin using pre_get_post filter to hide posts depending on which user is logged. However the "parent page" selector in the WP "edit post" page uses a wp-json call to get existing pages.

This creates a big problem: logged user is not recognized and restricted posts are always hidden.

Is there a way to hook into those REST API calls (eg. wp-json/wp/v2/pages?context=edit) and pass the user nonce or any way to recognize the user?

I read a lot about the X-WP-Nonce parameter, but I'm not creating a new REST call. I need to hook in existing ones.

1 Answer 1

-1

You can recognize a user by passing user-id

Example:

https://example.com/wp-json/wp/v2/posts?author=1

This author parameter will recognize author posts and return those

1
  • This is not what I asked though. I need to recognize it into existing calls (eg. the one used by WordPress to search for parent pages in the "edit page" screen)
    – a-coder
    Commented Jan 9, 2023 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.