By mistake, I changed the admin user role to a standard user. so now am not able to login to the WordPress dashboard. How can I recover the user role?
Asked
Active
Viewed 259 times
1 Answers
0
If you reach database side, you can change with below SQL commands(or you can use update if it exists), and also flow this link;
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('admin', MD5('password'), 'firstname lastname', 'user@domain.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

Emre Demirkol
- 91
- 6
-
You should use `LAST_INSERT_ID()` instead of `max(id)` for the `INSERT INTO wp_usermeta` and use a single `INSERT` query. – CDuv Mar 07 '23 at 14:48