Created
February 13, 2018 17:23
-
-
Save ideadude/b65cb51984db740bd9fe5de2fd4b2a0e to your computer and use it in GitHub Desktop.
Create a WordPress administrator user account via PHP/FTP.
This file contains hidden or 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 | |
/* | |
Sometimes you have FTP access to a site, but don't have a WP administrator account. | |
You can use this code to create one. | |
1. Add this code into any plugin or theme file that you know will be run. | |
2. Visit /?createmyadministratoruser=1. | |
3. Delete the code you added. | |
*/ | |
function init_create_my_administrator_user() { | |
if(!empty($_REQUEST['createmyadinistratoruser'])) { | |
wp_insert_user(array( | |
'user_login' => 'tempadmin', //change this | |
'user_pass' => 'temppass123', //change this | |
'user_email' => '[email protected]', //change this | |
'role' => 'administrator', | |
)); | |
echo "Admin user created. Remember to delete the code you added for this."; | |
exit; | |
} | |
} | |
add_action('init', 'init_create_my_administrator_user'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment