I previously had a WordPressMU install, but this is deprecated and I’m trying to find my way around multisite.
I need to programatically create a new user account for a particular site. wp_insert_user looks like it does everything except say which site the user is for (perhaps it takes this from the domain the request was sent to?).
It’s important that the created user is a member on one blog (site), but not the other(s).
You can use the add_user_to_blog function after creating the user.
Assuming you have WordPress Multisite, with sites:
example.com
,foo.example.com
andbar.example.co
m and you want to add a new user tofoo.example.com
, then create a script and execute that script via a URL containingfoo.example.com/path/to/your/script.ph
.WordPress detects the URL, maps it to a blog and assigns users created by
wp_insert_user()
to that blog, and not to the other blogs.See the answer by Chittaranjan if you then want to add the user to a other blogs/sites, too.