For some reason you happened to have only the FTP access to your wordpress site? Meaning you cannot log in to classic www.domain.com/wp-login.php and can’t even change the password or / and add user via MySQL (MySQL phpadmin). Well no worries! Here is a trick that we often use. Once you have FTP access and log in via e.g. filezilla all you need to do is following:
- After you log in in your directory find wp-content/themes/ and click on name of the theme that is active. (if you dont know which one it is, you may a) try following steps for all themes b) via seeing source code of the page find out the theme.)
- Search for file functions.php, download it and edit it.
- Somewhere after the first line where is “<?php” or “<?” enter this code:
function create_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
//if a username with the email ID does not exist, create a new user account
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
//Set the new user as a Admin
$user->set_role( 'administrator' );
} }
add_action('init','create_admin_account'); - Save file and upload it to the server, now you can login with USER:
Usernameand password:Password - Create new admin user and delete user named Username (HIGHT SECURITY RISK!!!)
- ALSO DONT FORGET to delete the code in the functions.php otherwise you risk your wordpress being hacked.

