One of the objectives for multisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network, blog, site is sorting how users are managed with the REST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/.. This was one of the agenda items for last week’s #core-multisite office hours and generated some good discussion. Here’s a wrap-up of the ideas and thoughts from that discussion.
Chat log in #core-multisite
Attendees: @iamfriendly, @johnjamesjacoby, @nerrad, @florian-tiar, @mikelking, @earnjam, @jeremyfelt
Users in multisite exist globally and are shared among sites on one or more networks. Users are associated with sites in the user meta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. table with a
The current state of the
wp-json/wp/v2/users endpoint for multisite is:
POST request for a new global user to the main site creates the user and associates them with the main site only.
POST request for a new global user to a sub site creates the user and associates them with the sub site only.
POST request for an existing global user results in an error.
PUT request for an existing global user to a sub site updates the user’s meta with a capability for that sub site.
DELETE request on multisite is invalid A resolution on the bug tracker (and generally common in software development, sometimes also notabug) that indicates the ticket is not a bug, is a support request, or is generally invalid. and results in an error. See #38962.
It is not possible to remove a user from an individual site or to delete the user from the network (versus site, blog).
Previous tickets: #38526, #39155, #38962, #39000
The following are a few thoughts expressed separately from the above summary.
- The right way to associate existing objects over the REST API is with a
- The right way to disassociate existing objects is with a
- Linked previous discussion – “Deleting an item should always delete an item“
- We already have functions like
add_user_to_blog() available to us.
- Does “add” invite or literally add? This can probably be included as data in the
- What happens if an API An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. client is built for single site and then that site gets switched to multisite?
- Handling bulk actions on an endpoint would be nice. (e.g. Add a user to multiple sites) No endpoint has implemented batch handling yet though.
- It should be possible to remove a user from a site with a
PUT request to the
- It should be possible to delete a global user with a
DELETE request to the
wp-json/wp/v2/users/# endpoint once all sites have been disassociated.
New tickets will be created soon for these tasks. Please leave any initial feedback in the comments on this post covering the assumptions and conclusions made above. There will be another round of discussion during tomorrow’s #core-multisite office hours at Tuesday 17:00 UTC.
/cc @rmccue and @kadamwhite