1

Hi so I'm developing an integration with a customer's Wordpress site so that we can index the site and search across its content for them.

However I'm facing some issues while doing this :

  1. I am able to hit the posts endpoint of the customer using https://site_name/wp-json/wp/v2/posts (this endpoint is actually publicly visible). When I attempt to hit this endpoint with a username and application password I get an output with the following structure
[
  {
    "id": 1234,
    "date": "2024-08-15T14:28:07",
    "date_gmt": "2024-08-15T12:28:07",
    "guid": {
      "rendered": "some_guid_link"
    },
    "modified": "2024-08-15T14:45:45",
    "modified_gmt": "2024-08-15T12:45:45",
    "slug": "some_slug",
    "status": "publish",
    "type": "post",
    "link": "post_url",
    "title": {
      "rendered": "Title rendered correctly"
    },
    "content": {
      "rendered": "",
      "protected": false
    }

If you see above the content rendered is an empty string while all other fields are rendered correctly. For some additional context

  1. The user has a Subscriber role in the Wordpress admin dashboard
  2. The customer has the following plugins installed
Advanced Custom Fields PRO
Broken Link Checker
Classic Editor
Easy FancyBox - WordPress Lightbox Plugin
Force Login
GA Google Analytics
Public Post Preview
Redirection
Restrict Content by Role
Single Sign-on with Azure Active Directory
User Role Editor
WP Control
Yoast Duplicate Post

1 Answer 1

1

My guess is, there is a filter causing change to the post content on api call. Could you check if the problem persists only in api or subscriber can see the content on normal page?

The Restrict Content by Role plugin might be setting some rules that disallow subscriber role to view content in api calls.

I would start with disabling/enabling that plugin to see if that's the cause. If not, I would do the same with other plugins one by one to verify if problem is caused by particular plugin.

If the problem persists outside of installed plugins, there must be custom code (custom theme or child theme), filtering post contents. If that's the case I recommend looking through the list of filters to find ones that might be worth hooking into. If problem is in api only I would start with hooks prefixed with rest_.

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.