XF 2.1 User API Secondary Groups

UrbanMC

Member
I'm trying to update the user's secondary groups using a super user api key. I want to add the user to group 5, which is a test group I've created. I'm getting a success message but the secondary groups haven't changed. Anyone know why it's not updating?

PHP:
<?php

$vars = [
    'api_bypass_permissions' => 1,
    'username' => 'admin',
    'secondary_group_ids' => [4, 5],
];


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://urbanmc.tk/api/users/3/");
curl_setopt($ch, CURLOPT_POST, count($vars));
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
    'XF-Api-Key: aJUEI0nrtucqizaO_ExOTjGK95L0DnaI',
    'XF-Api-User: 1',
    'Content-Type: application/x-www-form-urlencoded',
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec ($ch);

curl_close ($ch);

print  json_encode($server_output);

?>
 
Top