title: Create a wordpress user from an external script post
body: <p>An external script from a different url will send a curl post with user information such as (username, password, first name, last name, etc) to a script located somewhere in my wordpress installation in order to create the user. </p>
  
  <p>So far I have this but I think it is not working:</p>
  
  <pre><code>&lt;?php
      require_once('wp-includes/registration.php');
  
      $user_name = $_POST["username"];
      $user_email = $_POST["email"];
  
      $user_id = username_exists( $user_name );
  
      if ( !$user_id ) {
          $random_password = wp_generate_password( 12, false );
          $user_id = wp_create_user( $user_name, $random_password, $user_email );
      } else {
          $random_password = __('User already exists.  Password inherited.');
      }
  ?&gt;
  </code></pre>
  
  <p>1) What would be the basic skeleton of this script to receive a post and insert the user into the database? Like what files should it "require_once"?</p>
  
  <p>2) Where would it be best to locate this script in the wordpress installation? (I will need to provide the external script with the script url so they can post the users' info)</p>
  
  <p>Please help</p>