Roles and permissions
Morphic checks every request against one set of rules. Administrators can do everything, unless an API key limits the request. Other users and API keys get access only when a model's rules or a matching key allow it.
Knowing the order explains why a user sees a model but cannot edit it, and why an entry is missing from the API.
Administrators
A user is an administrator when WordPress gives them the manage_options capability. Administrators pass every check, including See hidden fields, unless an API key limits the request.
Only administrators see Models, Webhooks and Import from WordPress in the menu. Only administrators see Settings in the footer. Other users see Home, Content, API & integration, and Help & docs.
The order of checks
For each request on a model, Morphic checks these steps in order. The first check can refuse the request. Otherwise, the first check that allows it ends the check:
- A request with an API key that does not allow the action is refused for create, edit and delete, and for administrators.
- The user is an administrator. The request is allowed.
- The request uses an API key that allows the action. A key allows the models it lists, or every model when it lists none. Creating, editing and deleting need the Can also create, edit and delete setting on the key.
- The action is See hidden fields. Only the
morphic/can_fullfilter decides. The model's rules are not read. - The model's rules for the action, in the order they are stored. The first matching rule allows the request: Everyone, Logged-in users, a role or a WordPress capability.
If no step allows the request, Morphic returns the error you may not <action> <model>, for example you may not read book.
Access rules for a model
Each model has rules for four actions: See entries, Create, Edit and Delete. Each model's Access tab shows these as rows. Each row lists who may do that action. See hidden fields is not set by these rules. The morphic/can_full filter decides it.
- Everyone allows anyone, without logging in. Use it for content your website shows to visitors.
- Logged-in users allows anyone with an account on the site.
- A role column allows the people with that role. Administrators are not listed because they always have access.
An empty row means only administrators can do that action.
Quick setup applies a common pattern to all rows:
- Public website: everyone can see, and editors manage.
- Members only: logged-in users can see, and editors manage.
- Private: only administrators.
Use Advanced: allow by WordPress permission only when a plugin adds its own permission, such as a membership or shop plugin. Select Add permission to add it to a row. Everyone with that permission gets access, whatever their role.
Hidden entries and the bin
An entry is hidden when its publishing field is not set to published. Users who cannot edit the model see only published entries in lists. Users who can edit see all entries.
Deleted entries are in the bin. To list them, a user needs the Delete right. Without it, Morphic returns you may not see deleted <model>.
Full data, hidden fields and secret fields
Without See hidden fields, the API leaves out fields marked as hidden.
Secret fields work in two ways:
- A field with the hash setting always returns
<redacted>, even for users with See hidden fields. - A field with the seal setting returns its value only to users with See hidden fields, and only when a plugin provides the value. Otherwise it returns
<redacted>.
Secret and hidden fields are never printed on the site. Shortcodes and block-bound values return nothing for them.
Relations
To change a relation, a user needs Edit on the model that holds the field.
Settings and import
Non-administrators who open Settings see the message Only administrators can change settings. Non-administrators who open Import from WordPress see Only administrators can import content.
Other users get a 403 error from the API key routes.