Answers.Body: <p>I think we have a client where a postcode look up (on Contact save) triggers creation of a Relationship being made. The Relationship connects the Individual to the Regional Group (contact of type Org'n). You could then use our Relationships as ACL extension to run your 'access rules' from. I will ping JoAnne to comment further if she can.</p>
  
  <p>From JoAnne:  I'll add to this rather than comment.</p>
  
  <p>There is a table in the db linking every postcode/suburb combination to one of the 200+ organisations of type "local group".  </p>
  
  <p>The initial relationship is created when a person signs up for a specified membership type. </p>
  
  <p>With any change in a member's primary address, the relationship is re-checked. If warranted, that relationship is ended and a new one created with the new local group.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-24T21:22:45.550Z
Answers.LastActivityDate: 2015-07-25T11:59:18.513Z
Answers.LastEditDate: 2015-07-25T11:59:18.513Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>Use a post hook on Address instead? You could even have that hook take care of the group move as well as the custom field move. Editing someone so that they meet Smart Group criteria probably wouldn't cause an update hook right away because the content of a smart group is only updated when someone looks at it (and that lookup exceeds the cache timeout).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-27T08:31:17.027Z
Answers.LastActivityDate: 2015-07-27T08:31:17.027Z
Answers.UserDisplayName: DaveFF
Body: <p>The use case I have is as follows:</p>
  
  <p>An organization has multiple chapters, and it's important to record which chapter the person is in.  For a variety of good reasons (e.g. ACLs), chapters are represented by adding the contact to a group.  When adding a contact to a group, a <code>hook_post</code> in an extension fires, and fills out a custom field with the name of the chapter they're in.</p>
  
  <p>However, the chapter of a member is determined by location, so we want to move to using smart groups that can automatically classify contacts into chapters.  However, when a user is added via Smart Group, the hook doesn't fire, and the custom field's not filled in.</p>
  
  <p>Any suggestions?  I'm open to reorganizing the data - but the users would really like to have folks automatically classified into chapters by geography (zip code ranges, etc.) and so I think this requires that chapters be set by smart group.  It's OK if an answer requires coding, I'm civix-savvy.</p>
  
  <p>This site is using CiviCRM 4.4.16, Wordpress 4.2.2.</p>
  
Tags: <extension><hooks><smartgroups>
Title: Firing a hook on smart group status change?
ThreadText: # Firing a hook on smart group status change?
  
  (Asked by: username_0 on 2015-07-24)
  
  The use case I have is as follows:
  
  An organization has multiple chapters, and it's important to record which chapter the person is in. For a variety of good reasons (e.g. ACLs), chapters are represented by adding the contact to a group. When adding a contact to a group, a `hook_post` in an extension fires, and fills out a custom field with the name of the chapter they're in.
  
  However, the chapter of a member is determined by location, so we want to move to using smart groups that can automatically classify contacts into chapters. However, when a user is added via Smart Group, the hook doesn't fire, and the custom field's not filled in.
  
  Any suggestions? I'm open to reorganizing the data - but the users would really like to have folks automatically classified into chapters by geography (zip code ranges, etc.) and so I think this requires that chapters be set by smart group. It's OK if an answer requires coding, I'm civix-savvy.
  
  This site is using CiviCRM 4.4.16, Wordpress 4.2.2.
  
  **Tags:** extension, hooks, smartgroups
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-07-24. Score: 1
  
  I think we have a client where a postcode look up (on Contact save) triggers creation of a Relationship being made. The Relationship connects the Individual to the Regional Group (contact of type Org'n). You could then use our Relationships as ACL extension to run your 'access rules' from. I will ping JoAnne to comment further if she can.
  
  From JoAnne: I'll add to this rather than comment.
  
  There is a table in the db linking every postcode/suburb combination to one of the 200+ organisations of type "local group".
  
  The initial relationship is created when a person signs up for a specified membership type.
  
  With any change in a member's primary address, the relationship is re-checked. If warranted, that relationship is ended and a new one created with the new local group.
  
  
  ---
  
  ### Answer by username_2 on 2015-07-27. Score: 0
  
  Use a post hook on Address instead? You could even have that hook take care of the group move as well as the custom field move. Editing someone so that they meet Smart Group criteria probably wouldn't cause an update hook right away because the content of a smart group is only updated when someone looks at it (and that lookup exceeds the cache timeout).
  
  
  ---
  
  