throw new API_Exception('Invalid Group id');
}
+ if (substr($group->visibility, 0, 6) != 'Public') {
+ throw new API_Exception('Group is not Public. Contact cannot be subscribed to this Group.');
+ }
+
$subscribe = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $email, $contact_id);
if ($subscribe !== NULL) {
function _civicrm_api3_mailing_event_subscribe_create_spec(&$params) {
$params['email'] = [
'api.required' => 1,
- 'title' => 'Unsubscribe Email',
+ 'title' => 'Subscribe Email',
'type' => CRM_Utils_Type::T_STRING,
];
$params['group_id'] = [
'api.required' => 1,
- 'title' => 'Unsubscribe From Group',
+ 'title' => 'Subscribe To Group',
'type' => CRM_Utils_Type::T_INT,
];
}