How to add WordPress Administrator using PHP
Sometimes you are catch in this situation: client just sent you FTP access to the site but no WordPress password/user info at all. What to do? Since you have FTP access, you can do anything you’ll like and I will show you how to do that.
First of all, login to the site via FTP and find index.php file in the root directory of the WordPress installation.
Go to the very end of the file and write down something like this:
1 2 3 |
$user_id = wp_create_user( 'cute_user', 'this-is-my-password', 'this@is.my.mail' ); $wp_user_object = new WP_User( $user_id ); $wp_user_object->set_role('administrator'); |
Now, simply run this site, by entering its url in the browser. Be sure to remove those lines after that! Now you can get into /wp-admin and login using cute_user as a login and this-is-my-password as a password. Of course you should use your own data.