3

I'm creating a membership-based site in D7, using Date, Calendar, and Entity Registration (which was very easy to setup). Only authenticated users may register for an event.

I'm trying to limit the number of events an authenticated user may register for during a certain time period (probably by month or by quarter), and I'm stuck. I created a field called 'Registration Count' for user accounts. And I created a rule that increments the counter when the user registers for an event.

But I'm trying to figure out:

  1. How do I prevent a registration based on the user's current registration count? I got as far as creating a rule that is triggered prior to a registration and checked his current registration count. And I can display a warning, but the registration still goes through. Isn't there an action I can assign that would halt the registration?
  2. How can I reset the registration counter field for all user accounts back to zero at a certain interval? I can't find access to user fields on that broad level.

Adding more details:

I have a node type called "Event". My registrations are entities. This is out-of-the-box functionality for the Entity Registration module, and it was very simple to get it up and running.

Each user has a field called field-registration-count. When a user registers for an event, I have a rule set up as follows:

  1. Event: After saving a new registration
  2. Action: Set value site:current-user:field-registration-count, add offset 1. This increments the user's registration count by 1.

I have another rule:

  1. Event: Before saving a registration
  2. Condition: site:current-user:field-registration-count > 2
  3. Actions: Page redirect, and then Show a Message on Site

On the third registration, the page redirect happens as expected, and the message is displayed, but the registration is still saved. Based on the provided event named "Before Registration", I think I'm tapping in a the right time; I just can't find an action to cancel the registration itself

Note: When a user actually registers, it doesn't create a node. The Entity Registration module creates an entity type instead, and each registration is an entity.

0

1 Answer 1

1

Action to halt registration

Use "Page redirect", with a value for "URL" that could be either one of these:

  • some special node that you want to display to inform the user that the maximum number of events was reached.
  • the same URL that the user uses to add the event, combined with "Show a message on the site" whereas the message content provides appropriate information to the user that the maximum number of events was reached.

If that doesn't help/work, then you may want to try a variation of my answer to the question about How to restrict access to a node via node/12 and allow access via a path like content/sometitle? (that question was about "Node is 'going' to be viewed, while yours is about something like "entity is 'going' to be created").

Reset registration counter

Similar to the "Registration Count" field that you added, add another field like "Count start date". And each time a user tries to create a new event, just use that "Count start date" to compare it with the "current date": if then the time span between those 2 dates is longer then that "certain interval", then reset the "Registration Count" to zero.

4
  • I tried page redirect, but the registration still completed.
    – Mark
    Commented Jul 11, 2015 at 15:45
  • Hm, can you then enhance your question by adding more details what exactly you use as "Event(s)" and "Conditions"? I start to think that your "action" is coming too late (because there is something wrong in your "event" that you are looking for). Commented Jul 11, 2015 at 16:05
  • Sure I'm adding it to the original question.
    – Mark
    Commented Jul 12, 2015 at 4:43
  • Thanks for the suggestion on resetting the registration count. I think that will work. I was originally wanting to reset all users on the same date (e.g. first day of the quarter), but your way might be easier, and it's similar in outcome. Now if I can figure out how to prevent the registration. I might have to tie an action to viewing an event, rather than during the registration attempt.
    – Mark
    Commented Jul 12, 2015 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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