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

WordPress Trac noreply at wordpress.org
Tue Nov 8 01:32:41 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 jeremyfelt):

 I think I misunderstood the original issue at some level.

 In the current state, if I create a new user via `POST src.wordpress-
 develop.dev/site-two/wp-json/wp/v2/users`, the user is added to the
 network **and** the site as expected.

 If I attempt to use a create request for a user that already exists on the
 network, an error is returned.

 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.

 So for the client:

 * Request 1: Create user, error response - user_name
 * Request 2: Update existing user with roles, success.

 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.

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


More information about the wp-trac mailing list