Skip to content

Instantly share code, notes, and snippets.

@lgaetz
Last active February 18, 2019 16:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lgaetz/a6cc6139aefcb711a9de2f634690ceb6 to your computer and use it in GitHub Desktop.
Save lgaetz/a6cc6139aefcb711a9de2f634690ceb6 to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Script: lgaetz-usermandel.php
*
* Latest version: https://gist.github.com/lgaetz/a6cc6139aefcb711a9de2f634690ceb6
*
* Usage: Scipt to delete a FreePBX User Management user. Developed for FreePBX 14
*
* lgaetz-usermandel.php <Username>
* username - User Management username
*
*
* License: GNU/GPL3+
*
* History:
* 2019-01-15 First commit by lgaetz - very basic but working
*
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/
// FreePBX Bootstrap environment
include '/etc/freepbx.conf';
$FreePBX = FreePBX::Create();
// TODO add check to see if User Management module is installed
// script requires a username to delete - exit if not provided
if (isset($argv[1])) {
$deluser = $argv[1];
} else {
echo "No args provided, exiting.";
exit;
}
// get full user details
$user_details=$FreePBX->Userman->getUserByUsername($deluser);
// if id is returned, use it to delete user
if (isset($user_details['id'])) {
$delete=$FreePBX->Userman->deleteUserByID($user_details['id']);
}
// echo delete status
if ($delete['status']=='1') {
echo $deluser." ".$delete['message'];
} else {
echo "User delete failure";
}
@sorvani
Copy link

sorvani commented Jan 15, 2019

I added a newline because the prompt was coming up right after the message.
https://gist.github.com/sorvani/00e1e177cd63f91211cf742e2588f3ea/revisions
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment