Last active
February 18, 2019 16:32
-
-
Save lgaetz/a6cc6139aefcb711a9de2f634690ceb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I added a newline because the prompt was coming up right after the message.

https://gist.github.com/sorvani/00e1e177cd63f91211cf742e2588f3ea/revisions