[wp-trac] [WordPress Trac] #39544: REST API: Improve users endpoint in multisite
WordPress Trac
noreply at wordpress.org
Thu May 4 09:41:15 UTC 2017
#39544: REST API: Improve users endpoint in multisite
----------------------------+-----------------------------
Reporter: flixos90 | Owner:
Type: task (blessed) | Status: new
Priority: normal | Milestone: Future Release
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: | Focuses: multisite
----------------------------+-----------------------------
Comment (by flixos90):
@jnylen0
> we follow the rule that API clients don't need to be multisite-aware
I'm not convinced by introducing a separate endpoint for that behavior, as
I'm not fully of the opinion that a client shouldn't need to be multisite-
aware. After all multisite works differently in some points, particularly
user management, so why ignore that in the API? We're introducing a
`global` parameter, so I think it should be honored properly on all
`wp/v2/users` routes, so without specifying that parameter in `POST
wp/v2/users` no global operation should happen, as that would be
inconsistent.
Even now, for example you cannot delete users through the REST API in a
multisite while you can without multisite. Of course this is only because
we couldn't get it ready, but that is particularly because it works so
differently.
> The more I think about it, the more I'm realizing that the thing is
tripping us up is (c). Everywhere else in the REST API, the following rule
holds true: "a POST to a resource without an ID is a CREATE operation".
Let's not break it here.
My understanding is that, for a single site administrator adding an
existing user (multisite) has the same effect as creating a new user
(single site). So while from a global point of view it isn't a CREATE
operation, it is one when seen in the site context (thus without `global`
parameter).
> We could add a new endpoint like `/wp/v2/users/:id/sites`.
If the consensus ends up not to change the existing single site behavior
(`POST wp/v2/users` adds a global user and adds them to the site), I'd
still prefer finding a way to handle adding an existing user to the
current site with the infrastructure already present, for the above
reasons. For example `POST wp/v2/users?email=...&existing=true`.
What I wouldn't like in particular is if we didn't support adding existing
users to a site in the `CREATE` route while at the same time supporting
removing users from a site in the `DELETE` route. Either `POST
wp/v2/users` ''and'' `DELETE wp/v2/users/<id>` should be able to
add/remove users to/from a site independently from creating/deleting, or
neither of them should.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39544#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list