Multisite user creation does not add user to any sites #2327
I modified the plugin by adding this after the user has been created correctly:
This seems to work for users who have never registered to any blogs on the MU site, and the community role of "member" is hard-coded.
However if the user has already registered to one of the existing sites, the code never reaches this point.
My current hack for that is the following, which probably is far from ideal (and I am not sure if it is always the expected action to add an existing user to a new site using this call, so you might want to add proper API support for site member administration):
Can you share the request you're making, the response you receive, and the response you'd expect to receive?
Based on your report, it appears you want to assign a user to a site if they already exist. This isn't a use case WP-API currently supports (related #1922). Until it does, a better approach would be to create your own endpoint for user assignment.
We strongly discourage modifying plugin files because doing so prevents you from easily updating. As I mentioned before, a more reliable approach is to create your own endpoint for this need.
I am calling the following URL
This creates an user to the main domain. There is no way for me to add that user to the network of my-multisite-subdomain using the API.
What I would expect is that as I am calling the API using my multisite subdomain, the user would be automatically added to the network of the site specified by that subdomain. Currently it just gets added to the users of the whole multiuser wordpress thingy, so the blog at my-multisite-subdomain.maindomain.com does not see this user in it's network.
I would expect the call to return a redirect to the created user, as I think it does.. Currently there is a curious situation of you being able to fetch the user, but not being able to see the user in the listing of users (as the listing lists only users within the subdomain you are using the API from). I have not verified this, but I expect this to be the case.
To retain a proper REST api design, you might be correct that it is not a good idea to use this POST request to add an existing user to the current subdomain. A better approach might be to just return an error in this case when you are trying to add an user whose username or email is already taken in the site. The coder can then decide to use a separate API endpoint to add that particular user to the site (when such an API endpoint exists).
However I still think that it would be a good idea to have fresh users be automatically added to the site of the subdomain where the api is called from.
Just throwing my hat into the ring for when it comes to the multisite expansion. It's about time I dived into the REST API and it seems appropriate that it would be for MS stuff. Is there a plan for this already in place (if so where can I find it) or is there a meeting coming up (if so when) and if neither, would you REST API folk want someone to run with that? Naturally, Jeremy would be the most ideal person, but if he doesn't want to or can't dedicate the time, I'm happy to put my hand up. As always, thanks so much for your work on this :)