Close Menu
    Facebook X (Twitter) Instagram
    Oixiesoft
    • Home
    • Services
      • WordPress Malware Removal
      • Fix WordPress Errors
      • WordPress Website Development
    • Articles
    • Contact
    Oixiesoft
    Home»Wordpress»How to Add an Admin User in WordPress using FTP
    Wordpress

    How to Add an Admin User in WordPress using FTP

    Editorial StaffBy Editorial StaffUpdated:September 27, 2025No Comments2 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Sometimes we lose access to the WordPress site backend, and we need to regain it. We may lose access due to various reasons like forgetting the user name and password, site hacked, etc. If you have only FTP access to the site, In that situation, you can create a new admin user very easily via FTP.

    So, we will learn how to create WordPress admin via FTP in this tutorial.

    How to Add an Admin User in WordPress using FTP

    How to Add an Admin User in WordPress using FTP

    For creating administrator, First you need to connect via FTP. You can use third party FTP client like Filezilla, Winscp etc.to connect your site.

    Once login to the site, Go the the active theme function.php file. Add the below code to the function.php file and save it.

    function wpb_admin_account(){
    $user = 'Username';
    $pass = 'Password';
    $email = '[email protected]';
    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','wpb_admin_account');
    
    

    In the above code, replace the following:

    • $user with the username
    • $pass with the desired password
    • $email with the email address

    Now open the following URl in your browser
    yoursite.com/wp-login.php

    When you open this url, the above code will execute. It creates the new admin into the database. Now fill the respective details and login with the new admin. You can delete the code from the function file after getting the access to your site.

     

    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    Editorial Staff

    Related Posts

    WordPress Pharma Hack – How To Fix

    How to Set Post Expiration Date in WordPress

    How to Enqueue Scripts Using wp_enqueue_scripts Hook in WordPress

    WordPress Pharma Hack – How To Fix

    How to Set Post Expiration Date in WordPress

    How to Enqueue Scripts Using wp_enqueue_scripts Hook in WordPress

    How to Update PHP in WordPress Safely

    How to Fix Broken Permalinks in WordPress?

    Fixed Unable to Create Directory wp-content/uploads. Is its Parent Directory Writable by the Server.

    WordPress Memory Limit – How to Fix or Increase the PHP Memory Limit

    How To Fix Japanese Keyword Hack In WordPress Site?

    How to Add Bullet Points & Numbered Lists in WordPress

    How to Properly Use Heading Tags in WordPress

    How To Fix the “Missing a Temporary Folder” Error in WordPress

    How to Create a Sitemap in WordPress

    How to Disable Emojis in WordPress

    How To Turn Off The RSS Feed In WordPress

    How to Enable Customer Tracking in WooCommerce with Google Analytics

    How to Easily Add Icon Fonts in Your WordPress Theme

    How to Display Your Facebook Page Reviews in WordPress

    How to Start a Podcast (and Make it Successful) in 2024

    How To Fix “The Link You Followed Has Expired” WordPress Error

    How to remove Malware from WordPress website?

    Services
    • Web Development
    • Mobile Application Development
    • WordPress Malware Removal Service
    • Website Design
    • WordPress Development
    • Magento Development
    • Shopify Development
    • SEO Services
    Blog
    • How to Fix the Error Establishing a Database Connection
    • Ping List WordPress
    • How To Fix Japanese Keyword Hack
    • How to remove Malware from WordPress
    Hire Developers
    • Hire WordPress Developer
    • Hire Shopify Developer
    Contact Info
    • Oixiesoft Technologies
      A-40, Block A, I thum Tower, Sector 62, Noida
    • [email protected]
    • Privacy Policy
    • About Us
    • Contact Us
    © 2025 OixieSoft Technologies

    Type above and press Enter to search. Press Esc to cancel.