wp create user programmatically
To create a user programmatically in WordPress, you can use the wp_insert_user()
function. Here are the steps to do this:
- Use the
wp_create_user()
function to create a new user with a username, password, and email. - Set the user's role using the
wp_insert_user()
function, specifying the user_id and the role you want to assign (e.g., 'administrator', 'editor', 'author', 'contributor', or 'subscriber'). - Additional data such as first name, last name, and display name can also be added using the
wp_insert_user()
function.
That's it! This process will programmatically create a new user in WordPress with the specified details and role.