WordPress, with its user-friendly interface and powerful features, is the go-to platform for millions of websites. However, there may be instances where you find yourself locked out of your admin account, facing the daunting challenge of regaining access to your site. In such situations, having an alternative method to restore control becomes crucial.
One effective way to address this concern is by adding a new admin user to WordPress through a simple code tweak.
Imagine a scenario where you cannot access your WordPress admin account, and traditional methods like changing the password or using the standard login page prove ineffective. This situation can be frustrating, especially when you need to make urgent updates or address critical issues on your website.
Adding a New Admin User via FTP
To overcome the hurdle of a locked admin account, you can utilize a clever hack by adding a new admin user through FTP. This involves inserting a code snippet into your theme’s functions.php file, providing you with an alternative way to regain access to your WordPress site. Let’s walk through the process step by step.
Step 1: Accessing Your Theme’s Functions.php File
Firstly, connect to your WordPress site using FTP (File Transfer Protocol). Navigate to the “wp-content” folder and then access the “themes” directory. Locate the folder corresponding to your active theme, and inside it, you’ll find the functions.php file.
Step 2: Inserting the Code Snippet
Open the functions.php file in a text editor and scroll to the end of the file. Copy the following code snippet:
function wpb_admin_account(){
$user = 'techhyme';
$pass = 'Techhyme@123';
$email = 'info@techhyme.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' );
}
}
add_action('init','wpb_admin_account');
Step 3: Customizing the Code
Replace the placeholder values (‘techhyme‘, ‘Techhyme@123‘, ‘info@techhyme.com‘) with your desired username, password, and email address. Ensure that the chosen username and email are not already in use to prevent conflicts.
Step 4: Save Changes
Save the changes to the functions.php file and upload it back to your server using FTP.
Conclusion
By following these simple steps, you’ve successfully added a new admin user to your WordPress site, providing a failsafe method to regain access in critical situations. While this approach can be a lifesaver, it’s essential to use it responsibly and only when necessary. Regularly monitoring and maintaining your site’s security practices is the key to preventing such emergencies and ensuring a smooth WordPress experience.
You may also like:- Extracting .wpress Files with Wpress-Extractor
- Hackers Exploit Severe WordPress Plugin Vulnerability
- Critical SQL Injection Vulnerability in LayerSlider Plugin Threatens 1 Million WordPress Sites
- Best WordPress SEO Plugins for Enhanced Website Rankings in 2024
- 3 Best WordPress Plugins to Stop Clickjacking
- WordPress Security Checklist – 2024 Updated List
- 22 Important Key Terms Used in WordPress Website Development
- How to Prevent Malware Attacks on WordPress
- How To Force User To Login Into WordPress With Username
- Hide Your WordPress Login Error Message – A Brief Guide