3

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?

4

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!

  • 2
    Oh, 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!) – Andrew Hunt Aug 10 '15 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.