There is nothing worse than losing access to your admin account of WordPress. This could be down to a number of reasons! Today I will show you how you can add a WordPress admin user easily via FTP.
Step 1: Connect to you website via FTP
Step 2: Go to your public_html directory and find your WordPress installation folder. Go to wp-content – themes – yourthemename – functions.php.
Step 3: Right click on functions.php and choose edit. The functions file will open in your text editor
Enter this code
function dmw_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = mail@example.com';
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', dmw_admin_account');
Step 4: Once you have entered all of your details in the function above. Save the file. Now you will be able to log in using your details that you entered. Please ensure you delete that function once you are finished.