Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created October 19, 2021 09:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thierrypigot/2a3a50ff5bc32fa4afea261298852546 to your computer and use it in GitHub Desktop.
Add a WordPress Admin User to the Database via PHP
<?php
add_action( 'init', function () {
$username = 'wearewp';
$password = 'password';
$email_address = 'contact@wearewp.pro';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
$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