Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

create wordpress user programatically

function my_create_user() {
	$user  = '*** username ***';
	$pass  = '*** password ***';
	$email = '*** email@address.com  ***';
	if ( !username_exists( $user ) && !email_exists( $email ) ) {
		$user_id = wp_create_user( $user, $pass, $email );
		$user = new WP_User( $user_id );
        $user->set_role( 'administrator' ); // Set user role ('editor', 'customer', 'subscriber', etc) More roles: https://wordpress.org/support/article/roles-and-capabilities/#summary-of-roles
	}
}
add_action('init', 'my_create_user');
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #create #wordpress #user #programatically
ADD COMMENT
Topic
Name
2+3 =