How to Create Simple User Programmatically:
In this tutorial, we will create a WordPress or woocommerce simple user programmatically using either the wp_create_user() or wp_insert_user() functions. We will also show you the difference between them and look through some examples.
Difference Between wp_create_user() and wp_insert_user().
These functions will only allow you to provide a username, password, and email when creating a user. A user will be created with a default role, which is set in Settings > General.
You can change this value in settings.
More than that, wp_create_user() works on the base of wp_insert_user().
Now, let’s create a subscriber user with a username and password. We’ll use both functions to do that so you can understand the difference more clearly.
wp_create_user() way:
wp_insert_user() way:
Once you run this code, a new user will appear in WordPress admin: