Skip to content

Instantly share code, notes, and snippets.

@simsketch
Last active April 13, 2017 16:37
Show Gist options
  • Save simsketch/f33eaa58f6957dce8d24b0dfeaaae65d to your computer and use it in GitHub Desktop.
Save simsketch/f33eaa58f6957dce8d24b0dfeaaae65d to your computer and use it in GitHub Desktop.
Add admin user to WordPress site via FTP
// Add this to the the functions.php inside your active theme's directory ie: wp-content/themes/twentyseventeen/functions.php
// Not sure what your active theme is? You should be able to figure that out by viewing the source, and looking at the stylesheet.
function wpb_admin_account(){
$user = 'username';
$pass = 'password';
$email = '[email protected]';
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','wpb_admin_account');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment