Skip to content

Related users always show 'search failed' #4

@woutervroege

Description

@woutervroege

Bug Description

When using the User field in Open Fields, typing in the search box always shows “Search failed”.

In browser/network logs this appears as:

404 rest_no_route
No route was found matching the URL and request method.
Root cause:

The plugin registers REST routes under namespace codeideal-open-fields/v1
But the relational field JS was requesting openfields/v1/...
That namespace mismatch causes a 404 before permissions are even checked.
Example of failing request:

/wp-json/openfields/v1/search/users?... (wrong)
Correct route:

/wp-json/codeideal-open-fields/v1/search/users?... (right)

Fix Applied

I made two changes in the plugin:

Corrected REST namespace in relational JS

File: wp-content/plugins/codeideal-open-fields/assets/admin/js/relational-fields.js
Changed:
openfields/v1/search/posts -> codeideal-open-fields/v1/search/posts
openfields/v1/search/users -> codeideal-open-fields/v1/search/users
Relaxed user-search permission for editors

File: wp-content/plugins/codeideal-open-fields/includes/class-cofld-rest-api.php
Updated permission check so user search is allowed for users who can either:
list_users or
edit_posts
This prevents non-admin editors from hitting a 403 on user lookup after route fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions