Programmatically create user in another Drupal site How can I programmatically create user in another Drupal site?

The setup: multisite installation, userbase should be partially shared. Both websites have DB credentials setup in the settings.php file so I can query all tables from either site.

The problem: if I use db_set_active() to switch the database to the second site, calling user_save() will invoke all hooks of modules that are installed on the first site, not on the second one. This causes errors if the sites have different modules.

How can I avoid this problem? Any thoughts on workarounds?

Thanks!
One clean way to do this is using a web service with the services module. You could then expand to being able to create users through javascript or another server without direct access to that database.

It's easy to make your own resources to do exactly what you want.

It comes with native support for core functions, including registering users using the user resource. It's worth mentioning that the maintainers are happing to add new resources that support handling core functionality.

There's also other modules that extend services to provide single sign-on for example.