SAJIBDIGITAL | Web Design and Development Company in Bangladesh

How to Add a WordPress Admin Account via FTP? A Step-by-Step Guide

Forgetting your WordPress admin username, password, or email address, or finding yourself locked out of the admin area can be a frustrating experience. This guide will walk you through creating a new admin user using FTP, offering an alternative solution when traditional methods like accessing phpMyAdmin via cPanel are not feasible or desired.

Why and When You Need This?

If you’ve forgotten your admin user password or email address and can’t access your WordPress site’s backend, you may face challenges. While changing the admin user password via MySQL (commonly done through phpMyAdmin in cPanel) is an option, it may not be accessible or preferred. This guide is particularly useful when you have FTP access but limited or no access to cPanel.

How to Add a WordPress Admin Account via FTP?

  1. Access FTP: Log in to your FTP client software and connect to your site.
  2. Navigate to functions.php: Go to the path /wp-content/themes/YOURTHEMENAME/functions.php
  3. Edit functions.php: Right-click on the functions.php file and choose “View/Edit/Modify.” Once downloaded, add the provided code to the bottom of the page.
Function Code

Founction Code

function add_admin_acct() {
    $login = 'your_username';
    $passw = 'your_password';
    $email = '[email protected]';

    if (!username_exists($login) && !email_exists($email)) {
        $user_id = wp_create_user($login, $passw, $email);
        $user = new WP_User($user_id);
add_action('init', 'add_admin_acct');

Ensure to replace ‘your_username,’ ‘your_password,’ and ‘[email protected]‘ with your desired values.

  1. Save and Upload: Save the functions.php file and upload it back to your website’s theme folder using the FTP client.
  2. Test the New Account: Visit your WordPress site’s login area and sign in with the user account you just added.
  3. Remove the Code: After successfully logging in, remember to delete the added code from the functions.php file.

I hope this guide has assisted you in learning how to create a WordPress admin user using FTP. If you require further assistance, feel free to contact me via the Contact page.

Wishing you a wonderful day ahead!