Last active
April 13, 2017 16:37
-
-
Save simsketch/f33eaa58f6957dce8d24b0dfeaaae65d to your computer and use it in GitHub Desktop.
Add admin user to WordPress site via FTP
This file contains 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
// 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