I have a request to enable making every new Group created (using search results -> Actions -> Add Contacts to Group) a group type Mailing List by default, thereby saving a user having to check the box next to Mailing List. Can I do that with a new extension, using one of these hooks?
1 Answer
Use hook_civicrm_pre to modify the group-to-be prior to saving in the database. Experiment a little with your hook function, adding the debug lines:
if ($op == 'create' && $objectName == 'Group') {
print_r($params);
die();
}
Try creating a group with the Mailing List checked and then creating a group with it not checked to see what it passes. Write your code so that the $params array on a group where Mailing List is not checked ends up looking like the case where it is checked. And obviously delete your debug!
-
2Oh, and publish the extension when you're done. I bet many people would like it. (Though you do need to be careful about access control groups also being mailing list groups--people can unsubscribe themselves out of permissions!) Aug 10, 2015 at 6:02