Lost Wordpress Admin Privileges
When a client’s WordPress site got hacked and their admin account was deleted from the database. Sometimes a WordPress site administrative permission had been removed by the culprit. You may be able to log into the admin area but you won’t see any of the admin functionality (for example the ability to make changes to plugins or themes), which happens when permissions are modified. This locked them out of their site without any other entry.
So nothing much you can do, you need to go into the phpMyAdmin and created a new admin user to grant them access. In this article, i will show you a step by step guide on how to create an admin user in WordPress Database via MySQL. First, you need to have access to your hosting control panel such as CPanel, Plesk or VestaCP and etc in order to go into the phpMyadmin page. If you don’t kindly requests your hosting provider to provide it to you.
Create a fresh backup of your WordPress MySQL database. You should have one always before make any changes with your site data. It allows you to rollback your database to the previous state in case if something went wrong.
Add an Admin User to the WordPress Database
To fix this issue, you have to add a new admin user to your database via MySQL. Like resetting your password via phpMyAdmin by following below steps.
Login to your hosting provider control panel (CPanel/Plesk/VestaCP) and launch phpMyAdmin which can be found in the Databases section.Once logged in to PHPMyAdmin, select the WordPress MySQL database. If you have multiple databases and not sure which is the WordPress database, you can find the name of the database from the WordPress wp-config.php file, e.g. define(‘DB_NAME’, ‘wpdb’).Once the WordPress database is selected a list of all the tables in the database is populated as seen in the below screenshot. Click on the table wp_users to access its content. The default WordPress table prefix is wp therefore if you just changed the prefix to jL1wp8, the table name will be jL1wp8_users.
You need to make a new account, so click on ‘Insert’. In the Insert form, add the following:
ID: Input any number but remember what it is because you’ll be using this number in the next step, i chose 8.user_login: Create a username to access the WordPress Dashboard.user_pass: A password for this username. Make sure to select MD5 in the functions menu.user_nicename: Add a nickname or something else that you want to refer yourself as.user_email: Add the email you want to associate with this account. You might want to try a different email in case the original one you used is compromised.user_url: Input the URL for your website.user_registered: Select the date/time for when this user is registered.user_status: Set to 0.display_name: Put the name you’d like to display for this user on the site.Click on the Go Button.
Next we are going to have to add the values to wp_usermeta table. Click on the wp_usermeta table and then click on the Insert tab just like the previous step. Input the following information:
unmeta_id: Leave this blank (it will be auto-generated).user_id: This is the id of the user you created in the previous step, which i chose 8.meta_key: This should be wp_capabilities.meta_value: insert this: a:1:{s:13:”administrator”;s:1:”1″;}Click on the Go Button.
Then, insert another row with this information:
unmeta_id: leave this blank (it will be auto-generated).user_id: this is the id of the user you created in the previous step, which i chose 8.meta_key: This should be wp_user_level.meta_value: Set to 10.Click on the Go Button.
Congratulations, you’ve created a new username. Use this to log into your wp-admin using the new username and password.
SQL query
For developers who want to speed this process up, you can simply drop this SQL query in your database.
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('8', 'demo', MD5('demo'), 'Your Name', '
[email protected]', 'http://www.test.com/', '2020-09-08 00:09:08', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '8', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '8', 'wp_user_level', '10');
Remember to change the databasename to the database you are working with. Also don’t forget to change the appropriate values such as your domain. Reminder again the default WordPress table prefix is wp therefore if you just changed the prefix to jL1wp8, the table name will be jL1wp8_users and jL1wp8_usermeta.
Conclusion
Try to login now and check whether you can access to the WordPress admin backend. Now you need to proceed with restore and active all plugins or themes you had. For example if WooCommerce lost its roles and capabilities when you reactivate it. Now, you need deactivate and delete via WordPress plugin. Then install WooCommerce back in order to restore it’s roles automatically.
The post Lost WordPress Admin Privileges appeared first on Wordpress Tip Guide Support Solution.
Artikel ini hanyalah simpanan cache dari url asal penulis yang berkebarangkalian sudah terlalu lama atau sudah dibuang :
https://www.jonloh.com/lost-wordpress-admin-privileges/