Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

suspend single user

Questions regarding the API
Application Programming Interface
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
schiwe
Posts: 11
Joined: Wed Dec 28, 2016 7:45 am

suspend single user
  • Quote

Post by schiwe » Wed Dec 28, 2016 2:17 pm

Hi there,
Please forgive my badly English.
How can i suspend a single user using php ?
Or maybe i shuld ask How can i change specific value of a user ?

Thanks in advance,
Tzachi
Top

schiwe
Posts: 11
Joined: Wed Dec 28, 2016 7:45 am

Re: suspend single user
  • Quote

Post by schiwe » Wed Dec 28, 2016 3:42 pm

I will replay to myself here ..

Code: Select all


// Server credentials
$vst_hostname = '10.0.1.20';
$vst_username = 'admin';
$vst_password = 'youradminpass';
$vst_returncode = 'yes';
$vst_command = 'v-suspend-user';

// Account to suspend
$username = 'demo';

// Prepare POST query
$postvars = array(
    'user' => $vst_username,
    'password' => $vst_password,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => $username
);
$postdata = http_build_query($postvars);

// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);

// Check result
if($answer == 0) {
    echo "User account has been successfuly Suspended\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}
Top


Post Reply
  • Print view

2 posts • Page 1 of 1

Return to “Scripting / API”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password