Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Json :
- { "title":"Supervisor",
- "type":"group",
- "og_group_ref": { "und": [{ "target_id": "1921" }]},
- "field_records": { "und": [{ "value": "5" }]}
- }
- /*
- * Implements hook_services_resources
- */
- function your_module_name_services_resources() {
- return array(
- 'add_user' => array(
- 'create' => array(
- 'help' => 'Add users to group',
- 'callback' => 'your_module_add_user_to_group',
- 'access callback' => TRUE,
- 'access arguments append' => TRUE,
- 'args' => array(
- array(
- 'name' => 'uid',
- 'type' => 'id',
- 'description' => 'The uid of the user to add in group',
- 'source' => array('data' => 'uid'),
- 'optional' => FALSE,
- ),
- ),
- ),
- ),
- );
- }
- /*
- * Call back to add the user
- */
- function your_module_add_user_to_group($uid) {
- $user_account = user_load($uid);
- $og_values = array(
- 'entity_type' => 'user',
- 'entity' => $user_account,
- 'state' => OG_STATE_ACTIVE,
- );
- //This is will add the group to the user.
- og_group('node', $your_group_nid, $og_values);
- user_save($user_account);
- return success;
- }
Add Comment
Please, Sign In to add comment