1

Is there a hook in ExpressionEngine that triggers when any one member is moved from group to another?

2

As Derek said, there isn't a hook for member group change, but you could accomplish this by using the two member update hooks provided by the Member Model in conjunction with the Cache Access provided by the Session Class.

Hook 1: member_update_start
In your method called by this hook store the member's existing group_id using the Session Class set_cache() method.

Hook 2: member_update_end
In your method called by this hook retrieve the existing group_id (set above) by using the Session Class cache() method and compare it to the updated group_id to see if it has changed.

This works well in my quick test.

|improve this answer|||||
  • +1 - i guess you mean member_id and group_id – GDmac Jan 24 '14 at 5:40
  • Ah, yes, that's what I meant. I updated my answer to correct this. Thanks! – Alex Kendrick Jan 24 '14 at 14:56
  • 1
    Of note on this (clever) solution: it will only work when changing member groups via the CP - those hooks won't fire when changing member groups programatically. – Derek Hogue Jan 24 '14 at 21:22
  • 1
    Derek, why not fire the hooks in your own code too :-) (i have the same problem with hooks not firing with the auto_expire extension, which just bluntly updates table where expire_date < now. Just add some hooks yourself) Hook, don't hack (MadeByHippo) – GDmac Jan 25 '14 at 10:04
1

Unfortunately not. Best you could do is run a cron job which replicates the exp_members table periodically, then compares it to the real table, and takes action on any members whose groups affiliations have changed.

|improve this answer|||||

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.