Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create an Admin user from functions.php
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = '';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.