PDA

View Full Version : Deleting Users Programmatically


keef0r
01-26-2016, 10:47 AM
We have a SSO script that creates and logs users in, but I am have having trouble with the delete aspect of it. I found in the docs there is a delete (http://vb5support.com/resources/api/vbapi/vb_api_user.html#delete) method available, but when I try to use it, I get the following error thrown:
[["auth_required"]]
I've noticed that this error is thrown from checkHasAdminPermission (http://vb5support.com/resources/api/missing%20namespace/vb_api.html#checkHasAdminPermission), but I haven't been able to find how to authorize the API call as an admin.

Any help would be appreciated.

Replicant
01-26-2016, 02:46 PM
checkHasAdminPermission() is checking for a valid control panel session. You will probably need to write a new class without the admin check and use that instead.

keef0r
01-28-2016, 04:48 AM
Thanks Replicant. We ended up going with a different route. We added this code right before we run the delete call:
$api->callApi('user', 'login', array($admin_username, $admin_password));
It's less than ideal having to put the admin creds in the file, but it was quick and easy, and served our purposes of moving onto other more important things.