Adding a WordPress User via PHP

by | Aug 29, 2020 | WordPress, Knowledge Base, Security

Occasionally it happens where we are inheriting a site developed by someone else where we have file system access, but not access to WordPress itself.  When this occurs, we can use PHP to create a new WordPress administrator account to let us into WordPress to take full control of the site.

Here is a block of code that can be used to create a new WordPress administrator.  Drop this into the functions.php file of the active theme and load the site.  In the background it will execute and create a new administrator account with the credentials specified below.  Edit the functions.php file again to remove this code so that it doesn’t execute each time the site is accessed.

Please, use this code only for good!  🙂

Note that if you have a security plugin such as Wordfence, you will receive a notification that a user was created outside of the WordPress installation. This is normal and can be ignored.

 

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *