Merge pull request #23961 from totten/master-mgdphp-caseacttype
[civicrm-core.git] / api / v3 / MailingEventSubscribe.php
index 7046fe166efc5679c5880685ac65e3d77792a171..8e64faa365335488c923ba85c60046679bad88ce 100644 (file)
@@ -38,6 +38,10 @@ function civicrm_api3_mailing_event_subscribe_create($params) {
     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) {