It is possible to create a new user by API with the following line:
$user_id = wp_insert_user( $user_data );
I wonder how to send the newly created user an email that contains his password? Is there any function in WordPress API that handles this job or should I create and send an email by myself?
I assume you are generating the password and adding it to the
$user_dataarray?If not, you can use this to generate a password –
And while there probably is a way of hooking in to the generic WP send password email, I just use my own. That way, I can customise the content, and make it look like other emails from my site.
Note that I have set up a Class for registration, so if you have not, you will need to remove instances of
$this->.