If you find yourself locked out of the admin section of your WordPress website after accidentally subscribing as a user, fear not – there are steps you can take to regain control and restore your administrative access.
1. Direct Database Access:
Access your website’s database using a tool like phpMyAdmin provided by your hosting provider. Locate the wp_users
table, find your admin user entry, and set the user_role to ‘administrator’. This can be done by changing the user_role column value to ‘a:1:{s:13:”administrator”;b:1;}’.
2. File Manager Method:
If you have access to your website files via FTP or File Manager in cPanel, you can navigate to the wp-content/plugins
directory. Locate the plugin causing the role changes and rename its folder to deactivate it. This should revert your admin role.
3. Emergency Recovery Script:
Create a file named emergency.php
and place it in your WordPress root directory. Add the following code:
<?php
define('WP_USE_THEMES', false);
require('wp-load.php');
$user = get_user_by('login', 'your_username');
wp_set_password('new_password', $user->ID);
Replace ‘your_username’ with your admin username and ‘new_password’ with your desired new password. After accessing the script through your browser, remove it immediately for security reasons.
4. Resetting Plugins:
If you have another plugin affecting user roles and can’t remember its name, reset all plugins. Rename the ‘plugins’ folder to ‘plugins_backup’ via File Manager or FTP. Access your WordPress dashboard; the plugins will be deactivated. Rename the folder back to ‘plugins’ to reactivate them one by one, identifying the troublesome plugin.
5. Contact Hosting Support:
If the above methods prove challenging, reach out to your hosting support. Provide details about the issue, and they may assist in making necessary changes or guiding you through recovery.
By following these methods, you should be able to regain access to your WordPress admin and rectify the unintended subscription that caused the lockout.
Remember to take precautions to prevent such incidents in the future, such as being cautious with user roles and thoroughly testing new plugins before activation.