wordpress create user php
// ADD THIS TO YOUR FUNCTIONS.PHP FILE AND THEN RELOAD ANY PAGE
/////////////////////////////////////////////////////////////////
add_action( 'init', function () {
// set username, password, and email address
$username = 'user';
$password = 'password';
$email_address = '[email protected]';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
$user = new WP_User( $user_id );
// set the role (administrator, contributor, subscriber)
$user->set_role( 'administrator' );
}
} );