SAJIBDIGITAL | Web Design and Development Company in Bangladesh
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.
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.
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);
$user->set_role('administrator');
}
}
add_action('init', 'add_admin_acct');
Ensure to replace ‘your_username,’ ‘your_password,’ and ‘[email protected]‘ with your desired values.
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!