Skip to content

Instantly share code, notes, and snippets.

@devwax
Last active May 21, 2021 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devwax/8c1fac4d26c5be37a569e323b3ca2e80 to your computer and use it in GitHub Desktop.
Save devwax/8c1fac4d26c5be37a569e323b3ca2e80 to your computer and use it in GitHub Desktop.
Create WordPress user
<?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