Page 1 of 1

How to use 'Mobile Phone Number' in custom commands

Posted: Sun May 04, 2014 1:55 pm
by uglystory
Hello,

In reference to my earlier post, there is indeed a way how to use user's mobile phone (or any other information) in your custom commands.
Please see the code below for some ideas.
If you uncomment the lines in the end, you will get all metadata of the specific user.

Regards,
Tamar

Code: Select all

#!/usr/bin/php -q
<?php

require_once('/usr/local/nagiosxi/html/includes/components/componenthelper.inc.php');

if ($argc > 1) {
	print "Username: $argv[1]\n";

	$user_id = get_user_id($argv[1]);
	print "ID: $user_id\n";
	
	$user_name = get_user_meta($user_id, "name");
	print "Name: $user_name\n";

	$user_mobile_number = get_user_meta($user_id, "mobile_number");
	print "Mobile number: $user_mobile_number\n";
}
else {
	print "No username was passed.\n";
	exit(1);
}

//$all_user_meta = get_all_user_meta($user_id);
//var_dump($all_user_meta);

?>

Re: How to use 'Mobile Phone Number' in custom commands

Posted: Mon May 05, 2014 9:15 am
by tmcdonald
Thanks for the post! Looks like you have a good grasp of the concept.