Create a New WordPress user without admin login through function.php file. Follow the below steps to create a user –
1. Copy the below code and paste into function.php file in the theme folder –
function wordpress_admin_user_account(){
$user = 'Your Username';
$pass = 'Your Password';
$email = 'youremail@xyz.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 like customer, administrator, subscriber, editor, contributor, author
}
}
add_action('init','wordpress_admin_user_account');
$user = 'Your Username';
$pass = 'Your Password';
$email = 'youremail@xyz.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 like customer, administrator, subscriber, editor, contributor, author
}
}
add_action('init','wordpress_admin_user_account');
2. Open Login Page and login as per the above details