/** * Add contact(s) to group(s). * * This api has a legacy/nonstandard signature. * On success, the return array will be structured as follows: * @code * array( * "is_error" => 0, * "version" => 3, * "count" => 3, * "values" => array( * "not_added" => integer, * "added" => integer, * "total_count" => integer * ) * ) * @endcode * * On failure, the return array will be structured as follows: * @code * array( * 'is_error' => 1, * 'error_message' = string, * 'error_data' = mixed or undefined * ) * @endcode * * @param array $params * Input parameters: * - "contact_id" (required): First contact to add, or array of Contact IDs * - "group_id" (required): First group to add contact(s) to, or array of Group IDs * - "status" (optional): "Added" (default), "Pending" or "Removed" * Legacy input parameters (will be deprecated): * - "contact_id.1" etc. (optional): Additional contact_id to add to group(s) * - "group_id.1" etc. (optional): Additional groups to add contact(s) to * * @return array * Information about operation results */ function civicrm_api3_group_contact_create($params) { // Nonstandard bao - doesn't accept ID as a param, so convert id to group_id + contact_id if (!empty($params['id'])) { $getParams = array('id' => $params['id']); $info = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $getParams); if (!empty($info['values'][$params['id']])) { $params['group_id'] = $info['values'][$params['id']]['group_id']; $params['contact_id'] = $info['values'][$params['id']]['contact_id']; } } $action = CRM_Utils_Array::value('status', $params, 'Added'); return _civicrm_api3_group_contact_common($params, $action); }
/** * Add contact(s) to group(s) * * @access public * * @param array $params Input parameters * * Allowed @params array keys are:<br> * "contact_id" (required) : first contact to add<br> * "group_id" (required): first group to add contact(s) to<br> * "contact_id.1" etc. (optional) : another contact to add<br> * "group_id.1" etc. (optional) : additional group to add contact(s) to<br> * "status" (optional) : one of "Added", "Pending" or "Removed" (default is "Added") * {@example GroupContactCreate.php 0} * * @return array Information about operation results * * On success, the return array will be structured as follows: * <code>array( * "is_error" => 0, * "version" => 3, * "count" => 3, * "values" => array( * "not_added" => integer, * "added" => integer, * "total_count" => integer * ) * )</code> * * On failure, the return array will be structured as follows: * <code>array( * 'is_error' => 1, * 'error_message' = string, * 'error_data' = mixed or undefined * )</code> * {@getfields GroupContact_create} */ function civicrm_api3_group_contact_create($params) { $action = CRM_Utils_Array::value('status', $params, 'Added'); return _civicrm_api3_group_contact_common($params, $action); }