I get form data through ajax and I want to use it and add a new user with a subscriber role. to the original Wordpress users and also send them a notification about their account. Here is the bit of code that I have so far.

function set_form()
    $fisrt_name = $_POST['fisrt_name'];
    $email = $_POST['email'];
    $email = $_POST['email'];
    $admin =get_option('admin_email');
    //Code to register user

add_action('wp_ajax_set_form', 'set_form');    //execute when wp logged in
add_action('wp_ajax_nopriv_set_form', 'set_form'); //execute when logged out

You could use the wp_insert_user function to create the new user. And then with the wp_new_user_notification function you could send the notification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.