Last active
May 21, 2021 19:39
-
-
Save devwax/8c1fac4d26c5be37a569e323b3ca2e80 to your computer and use it in GitHub Desktop.
Create WordPress user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function devwax_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' ); | |
} | |
} | |
add_action('init', 'devwax_create_user'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment