0

I am in a strange situation,

I installed wordpress on my godaddy hosting everything was fine and i developed my theme in nice way,

But now i cant login in wp-login.php, i try to reset my password but when password is resetting it taking me to the subscribers dashboard not on admin dasboard.

i can resgister on my site as subscriber

is there a way so i can change subscriber to admin from phpmyadmin ?

4
  • 1
    If you have access to PHPMyAdmin you should be able to find out which user has administrator rights in the usermeta table
    – Tom J Nowell
    Commented Sep 3, 2014 at 16:06
  • nothing is there, can any alternative way is present ... can i login from phpmyadmin or from files ..something like this Commented Sep 3, 2014 at 16:14
  • This sounds worrying, do you have backups? Do you have ssh/wp cli access?
    – Tom J Nowell
    Commented Sep 3, 2014 at 16:16
  • ya i have ssh access Commented Sep 3, 2014 at 16:21

5 Answers 5

0

If you have WP CLI, this is how you would make the user 'bob' an administrator:

wp user set-role bob administrator
3
  • i am not familiar with wp cli .. but i have access over ssh Commented Sep 3, 2014 at 16:35
  • Great if you go to wp-cli.org it'll tell you how to install it via the homepage
    – Tom J Nowell
    Commented Sep 3, 2014 at 16:42
  • i have shared linux hosting and i follow wp-cli installing guide they are saying u have to move wp-cli.phar to /usr/local/bin which needs roots privelages and hosting isnt allowing root access Commented Sep 3, 2014 at 16:59
0

I'm currently unable to test but, If you still have FTP access stick this somewhere and run it. Replacing $user_id with your ID and it should work.

$user = new WP_User($user_id);
$user->remove_role('subscriber');
$user->add_role('administrator');
0

In the table PREFIX_usermeta look for the PREFIX_capabilities key that is setup for the admin ID (probably 1).

You should be able to edit that row and change "subscriber" to "administrator"

0

Save this as new.sql file. Change wp_ suffix in this sql query with your wordpress database suffix. If you haven't change it then it will be wp_ by default.

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`) VALUES ('newadmin', MD5('pass123'), 'firstname lastname', '[email protected]', '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');

And upload it to your server. Then from ssh use this command to create a new admin user.

mysql -u username -p databasename < new.sql

replace username (make sure you add -u before username) with your mysql username and databasename with your wordpress database. It will ask for mysql password.

On successful extenuation it will create a new admin user with

username: newadmin

password: pass123

8
  • i did it but no success .... it is not taking user or password Commented Sep 3, 2014 at 16:50
  • What is the error?
    – Robert hue
    Commented Sep 3, 2014 at 16:50
  • it uploaded and everything is fine i can see user : newadmin in PREFIX_users. but @ login ERROR: Incorrect username or password. Commented Sep 3, 2014 at 16:56
  • Then you should be able to login to admin area. If it does not work, try copy new.sql again from above. I updated this code.
    – Robert hue
    Commented Sep 3, 2014 at 16:57
  • Then it should be issue with 'Authentication Unique Keys and Salts'. Try different browser.
    – Robert hue
    Commented Sep 3, 2014 at 16:58
0

Open Phpmyadmin. Find the wp-users table. Select the row containing your username. Click on Edit. For the password, select "MD5" from Functions column and then on the textarea, give your desired password.

Once it's done, you'll be able to login using your original username and password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.