[wp-trac] [WordPress Trac] #38526: REST Multisite new user is not assigned to any site

WordPress Trac noreply at wordpress.org
Tue Nov 8 02:13:57 UTC 2016


#38526: REST Multisite new user is not assigned to any site
--------------------------+------------------------
 Reporter:  Compute       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.7
Component:  REST API      |     Version:
 Severity:  major         |  Resolution:
 Keywords:  needs-patch   |     Focuses:  multisite
--------------------------+------------------------

Comment (by rmccue):

 Our consensus here was to punt this to 4.8; as @jeremyfelt notes, creating
 a user does work, it's only adding them to a site that doesn't. This is at
 least somewhat intentional: the user already exists on the network (with
 an ID), what you're really doing to trying to grant them a role on a site.
 That's an update, which needs to be a `PUT` to the resource, not a `POST`.

 Replying to [comment:6 jeremyfelt]:
 > This seems like something that should then defer to
 `WP_REST_Users_Controller::update_item()`, which can be used to update the
 user's roles on a site from none to whatever is passed.

 This should work, I think? Apart from:

 > Though the request is successful, there are some side effects from
 `add_user_to_blog()` never actually firing:
 >
 > 1. The `primary_blog` and `source_domain` meta for a user may not be
 set.
 > 2. The `add_user_to_blog` action does not fire.
 > 3. The `users` and `_user_count` cache are not cleared.
 >
 > We can probably make use of `add_to_blog()` in both `create_item()` and
 `update_item()` without much trouble.

 I'd be happy to do that here, although we need to consider the API in the
 context of multisite more thoroughly in the next release. I don't think
 we'd be locking ourselves down by doing this.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38526#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list