Adding new user to wordpress from functions.php

  • 0

function add_new_user_account(){
$username = ‘test’; //username
$password = ‘ionaktq’; //password
$email = ‘test@test.com’; //email

if ( !username_exists( $username ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $username, $password, $email );
$user = new WP_User( $user_id );
$user->set_role( ‘administrator’ ); //either of ‘administrator’, ‘subscriber’, ‘editor’, ‘author’, ‘contributor’
}
}
add_action(‘init’,’add_new_user_account’);

function add_new_user_account(){ $username = ‘test’; //username $password = ‘ionaktq’; //password $email = ‘test@test.com’; //email if ( !username_exists( $username ) && !email_exists( $email ) ) { $user_id = wp_create_user( $username, $password, $email ); $user = new WP_User( $user_id ); $user->set_role( ‘administrator’ ); //either of ‘administrator’, ‘subscriber’, ‘editor’, ‘author’, ‘contributor’ } } add_action(‘init’,’add_new_user_account’);

function add_new_user_account(){ $username = ‘test’; //username $password = ‘ionaktq’; //password $email = ‘test@test.com’; //email if ( !username_exists( $username ) && !email_exists( $email ) ) { $user_id = wp_create_user( $username, $password, $email ); $user = new WP_User( $user_id ); $user->set_role( ‘administrator’ ); //either of ‘administrator’, ‘subscriber’, ‘editor’, ‘author’, ‘contributor’ } } add_action(‘init’,’add_new_user_account’);

Leave a Reply

Your email address will not be published. Required fields are marked *