WordPress : Add Admin User in WordPress By FTP client.

This happens many times when we forget the login password of WordPress, Not to worry, we can add it by adding this code to your theme’s functions file using FTP client.

function AddAdminAccount(){
  $user = 'NewUsername';
  $pass = 'Password';
  $email = 'new@email.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' );

Please don’t forget to fill the username email password fields. And don’t forget to delete the code from your functions file after user creation.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top