Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8886533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:34:55+00:00 2026-06-14T21:34:55+00:00

It is possible to create a new user by API with the following line:

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:34:57+00:00Added an answer on June 14, 2026 at 9:34 pm

    I assume you are generating the password and adding it to the $user_data array?

    If not, you can use this to generate a password –

    $this->password = wp_generate_password(6, false);
    $user_data['user_pass'] = $this->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->.

    function prepare_email(){
    
            $confirmation_to = $_REQUEST['email_address'];
            $confirmation_subject = 'Confirmation - Registration to My Site';
            $confirmation_message = 'Hi '.$_REQUEST['first_name'].',<br /></br />Thank you for registering with My Site. Your account has been set up and you can log in using the following details -<br /><br />'
                .'<strong>Username:</strong> '.$_REQUEST['username']
                .'<br /><strong>Password:</strong> '.$this->password
                .'<br /><br />Once you have logged in, please ensure that you visit the Site Admin and change you password so that you don\'t forget it in the future.';
            $headers = 'MIME-Version: 1.0'."\r\n";
            $headers.= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
            $confirmation_headers = $headers.'From: My Site <no-reply@mysite.com>'."\r\n";
    
            $this->form_for_email = compact('confirmation_to', 'confirmation_subject', 'confirmation_message', 'confirmation_headers');
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering whether it is possible to create a new database and user,
Does anyone know if it is possible to create new user in Active Directory
is it possible to create new users (In-band registration) using anonymous user using Strophe.js
Is this possible to create new {variable = x.something} and specify variable name dynamically?
I am using Excel VBA 2003. Is it possible to create new recordset by
I'm using Umbraco 5. Is it possible to create new Document Type programmatically using
Is it possible to create a new folder for images (to be taken through
Is it possible to create a new document instead of getting an error when
Is it possible to create a new List<T> where the T is dynamically set
I am wondering if it is possible to create a new dataframe with certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.