Answers.Body: <p>I think the trigger should be 'participant changed' as you want to test this everyone time someone attends an event. </p>
  
  <p>The first condition would be something like 'participant status changed to registered'.</p>
  
  <p>I am not sure if you can combine membership conditions with a participant trigger, so checking the membership type would be weird (the data is not there when dealing with a participant of an event). But you could put all members in a group and then check if the participant is a member of that group.</p>
  
  <p>The third condition would be to count if it is the fifth, I do not think there is a ready made condition for that, so it would have to be developed (probably about 4 hrs work).</p>
  
  <p>The first action would be to send an email (you will need to install the Email API extension to do this: <a href="https://civicrm.org/extensions/e-mail-api" rel="nofollow noreferrer">https://civicrm.org/extensions/e-mail-api</a>).</p>
  
  <p>The second action would be to cancel the membership. At the moment there is no action to do this, so that would need to be developed (approx. 4 hrs work).</p>
  
  <p>I would recommend extensive testing too :-) CiviRules is powerful but also allows you to automatically send lots of emails. </p>
  
  <p>Good luck!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-10T03:00:34.143Z
Answers.Text: Thanks Erik. I thought maybe I need to add a number of rules to do this. So first rule would be if a new contribution is added then a tag is added to the contact of say '0', meaning zero event participation. Second rule would be when user with tag '0' is added as a participant a new tag '1' is added and the old tag '0' is removed. When they attend a second event the tag is changed from '1' to '2' and so on until the tag is '5'. When the tag '5' is added is triggers a change in membership status and sends a renewal email. Do you think that could work? I would need 6 rules to handle this?
Answers.UserDisplayName: Sarah D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-10T12:39:51.763Z
Answers.Text: Yes that could work in that way! And yes, you would need 6 rules. Pattern: trigger is new contribution, conditions financial type is event fee, contact is tagged as 1, action is remove tag 1 and set tag 2.
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-14T04:40:00.667Z
Answers.Text: I have set up the rules to add the contacts to the different groups based on how many events they have attended and it all seems to be working fine. How now do I remove their membership after the 5th event? I can see add a membership, but not remove a membership as an option.
Answers.UserDisplayName: Sarah D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-14T08:56:12.027Z
Answers.Text: As stated in my answer, there is no action yet to end a relationship. That would need to be developed. Do you have skills available that can do this? Documentation is here: https://docs.civicrm.org/civirules/en/latest/create-your-own-action/. If you do not, you will have to find an expert (https://civicrm.org/partners-contributors) to do this? It would be about 4 hrs of work.
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-14T20:59:46.213Z
Answers.Text: Thanks Erik. I'l give it a crack and see how I go.
Answers.UserDisplayName: Sarah D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-09T08:29:36.863Z
Answers.LastActivityDate: 2020-01-09T08:29:36.863Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I'm new to CiviRules. I have a membership type that I want to be an event based membership in that I want users to users to be able to attend 5 events and then their membership is cancelled. I guess the rule would be: When active member on 'event membership' type attends 5 events their membership is cancelled and a renewal reminder email is sent. Can anyone help me with how to set this up?</p>
  
Tags: <civimember><civirules>
Title: Rule to Cancel Membership After Certain Number of Events Attended
ThreadText: # Rule to Cancel Membership After Certain Number of Events Attended
  
  (Asked by: username_0 on 2020-01-09)
  
  I'm new to CiviRules. I have a membership type that I want to be an event based membership in that I want users to users to be able to attend 5 events and then their membership is cancelled. I guess the rule would be: When active member on 'event membership' type attends 5 events their membership is cancelled and a renewal reminder email is sent. Can anyone help me with how to set this up?
  
  **Tags:** civimember, civirules
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-09. Score: 1
  
  I think the trigger should be 'participant changed' as you want to test this everyone time someone attends an event.
  
  The first condition would be something like 'participant status changed to registered'.
  
  I am not sure if you can combine membership conditions with a participant trigger, so checking the membership type would be weird (the data is not there when dealing with a participant of an event). But you could put all members in a group and then check if the participant is a member of that group.
  
  The third condition would be to count if it is the fifth, I do not think there is a ready made condition for that, so it would have to be developed (probably about 4 hrs work).
  
  The first action would be to send an email (you will need to install the Email API extension to do this: <https://civicrm.org/extensions/e-mail-api>).
  
  The second action would be to cancel the membership. At the moment there is no action to do this, so that would need to be developed (approx. 4 hrs work).
  
  I would recommend extensive testing too :-) CiviRules is powerful but also allows you to automatically send lots of emails.
  
  Good luck!
  
  > **Comments:**
  > **username_0**: Thanks Erik. I thought maybe I need to add a number of rules to do this. So first rule would be if a new contribution is added then a tag is added to the contact of say '0', meaning zero event participation. Second rule would be when user with tag '0' is added as a participant a new tag '1' is added and the old tag '0' is removed. When they attend a second event the tag is changed from '1' to '2' and so on until the tag is '5'. When the tag '5' is added is triggers a change in membership status and sends a renewal email. Do you think that could work? I would need 6 rules to handle this?  
  > **username_1**: Yes that could work in that way! And yes, you would need 6 rules. Pattern: trigger is new contribution, conditions financial type is event fee, contact is tagged as 1, action is remove tag 1 and set tag 2.  
  > **username_0**: I have set up the rules to add the contacts to the different groups based on how many events they have attended and it all seems to be working fine. How now do I remove their membership after the 5th event? I can see add a membership, but not remove a membership as an option.  
  > **username_1**: As stated in my answer, there is no action yet to end a relationship. That would need to be developed. Do you have skills available that can do this? Documentation is here: https://docs.civicrm.org/civirules/en/latest/create-your-own-action/. If you do not, you will have to find an expert (https://civicrm.org/partners-contributors) to do this? It would be about 4 hrs of work.  
  > **username_0**: Thanks Erik. I'l give it a crack and see how I go.  
  
  ---
  
  