Delete User

Use the Delete User API to delete the user from the Virtualizor panel, by passing the user’s ID. The IDs can be obtained by the list users API. For deleting multiple users you need to the pass the IDs as comma separated values. The API response will contain “done” as the array of the user’s information after the user has been successfully deleted.

HTTP Request

https://hostname:4085/index.php?act=users

Parameters

NameMethodValueDescriptionRequired
actGETusersThe action will list the users after a specific operation is executedYes
deletePOSTIntThe ID of the users to be deleted. For deleting multiple users, pass in the IDs as comma separated valuesYes
delete_vms POSTIntIf this parameter is passed then it will delete the VM(s) of that user as well.
In case of deleting cloud user it will delete the subuser(s) and their VM(s) as well. If not passed then the VM(s) will become orphan. (Since 3.0.1+)
No

Sample Code

<?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['delete'] = 57;
    $post['delete_vms'] = 1; // For deleting VMs (optional)
    $post['delete'] = '58,59'; // for deleting multiple users

    $output = $admin->delete_users($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Users",
    "done": {
        "58": {
            "uid": "58",
            "email": "test@test.com",
            "dnsplid": "0"
        },
        "59": {
            "uid": "59",
            "email": "test_email@gmail.com",
            "dnsplid": "0"
        }
    },
    "users": null,
    "timenow": 1535987367,
    "time_taken": "0.229"
}
Was this helpful to you?