• Hi,

    Is there a script (in php for instance) which might allow me to add an user with a passord to the database of my multisite WordPress? A script outside WP, not a plugin.

    I ask this because I have a system for registration of users outside the WP frame. In that general space, when the user registers, I would like to give him an automatic WP blog/page.

    Is this possible?

    Kind regards

    JKepler

Viewing 3 replies - 1 through 3 (of 3 total)
  • You should be looking at using the REST API. This requires knowledge of coding but is how you would have other software communicate with WordPress.

    REST API explained in plain english:
    https://www.godaddy.com/garage/the-wordpress-rest-api-what-it-is-and-why-you-should-care/

    Thread Starter jkepler

    (@jkepler)

    Hi

    Yes, it is the best way. So I’ll create an end point with my own credentials. Just a question if I may: inside that endpoint, is it enougn then to place

    $user_id = wp_create_user( $username, $password, $email_address );
      wp_update_user(
        array(
          'ID'          =>    $user_id,
          'nickname'    =>    $username
        )
      );

    Must the user have and ID and both a username and nickname defined in wp_update_user? And I assume that the endpoint recognizes all these commands…

    Sorry for the trouble.

    Kind regards

    JKepler

    Moderator bcworkz

    (@bcworkz)

    No trouble at all. All PHP and WP functions are available in endpoint processing code. You don’t have to set a nickname, the create user function sets it to the login name by default. The create user parameters are all that is really required. Your update user code is redundant since the create user function already set the nickname to the login name. The only reason to reset it would be if you want the nickname to be different than the login name.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create user automatically’ is closed to new replies.