Created
February 22, 2018 03:02
-
-
Save nciske/2da1bd84688fabb79bb3baf0a6d937a2 to your computer and use it in GitHub Desktop.
Add an admin account for yourself to a WordPress site you have S/FTP or Git push access to
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
<?php | |
// add this to functions.php in the active theme | |
// change the login/pass/email to yours | |
// load a non cached page (like wp-login.php) | |
// log in | |
// delete the code | |
function add_admin_acct(){ | |
$login = "{your username}"; | |
$passw = "{your password}"; | |
$email = "{your email}"; | |
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