how-to-add-admin-user-using-FTP-wordpress

How to add Admin User in WordPress using FTP

In Wordpress by Hafiz Faraz MukhtarLeave a Comment

Creating WordPress admin user through FTP is easy. You might need this solution if

  • You are having trouble logging in to your WordPress
  • The password reset link is not working
  • You are a developer and client have not provided admin access
  • or any other related issue (please comment below)

Solution:

  1. Open FTP client such as FileZilla and login to your FTP account
  2. Navigate to wp-content/themes folder of your site
  3. Open the currently active* theme folder
  4. Inside active theme folder, open functions.php file
  5. Copy and paste the following code at the end of functions.php:

* To know the active theme name, in Chrome browser: Open DevTools  > Sources > Wp-Content > Theme ‘Active theme name will be visible there’.

function admin_account(){
	$user = 'Username';           // Enter unique username
	$pass = 'Password';           // Enter desired password
	$email = 'email@domain.com';  // Enter unique email
	
	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','admin_account');
    1. Change username, password, and email to something unique which has never been used on that site earlier.
    2. Save changes.
    3. Now open your WordPress site login page and login to your account
    4. You are now logged in.

Still having difficulty, contact us here

About the Author
Hafiz Faraz Mukhtar

Hafiz Faraz Mukhtar

Facebook Twitter

Hafiz Faraz Mukhtar is an expert Web Developer, SEO specialist, and Graphic Designer. Hafiz Faraz is an expert in WordPress design and development. If you would like to hire him, here is his Upwork profile link: https://www.upwork.com/fl/hfarazm

Leave a Comment