Skip to content

Instantly share code, notes, and snippets.

@sirjonathan
Created November 4, 2012 20:27
Show Gist options
  • Save sirjonathan/4013590 to your computer and use it in GitHub Desktop.
Save sirjonathan/4013590 to your computer and use it in GitHub Desktop.
Create New WordPress Admin Account
// Add to your active theme's functions.php
// Or, create a simple, must-use custom plugin:
// See: http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users
function add_admin_acct(){
$login = 'Username';
$passw = 'examplepassword';
$email = 'youremailaddress';
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' );
}
}
add_action('init','add_admin_acct');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment