From what I have seen, all checks (registration_has_room() and registration_status()) on whether slots are filled for a registration point back to registration_event_count(). It would be great to implement a hook_registration_event_count_alter() so developers can hook in there and alter the count.

My specific use-case is providing online courses where certain registration states I've defined, such as "withdrawn," don't occupy a slot, thus allowing another user to register for the slot that's opened up. So far, with the above described approach, I haven't found any gotchas.

Comments

mlsamuelson’s picture

Status: Active » Needs review
StatusFileSize
new660 bytes

Patch attached.

mlsamuelson’s picture

Title: Provide hook_registration_has_room_alter() so developers can hook in and alter counts. » Provide hook_registration_event_count_alter() so developers can hook in and alter counts.

Mis-identified the hook I meant to provide in the issue title. Updated that.

jameswoods’s picture

Thanks for posting this. I too had need to alter the counts and this hook allowed me to do so. I really appreciate you posting this hook.

-James

levelos’s picture

Status: Needs review » Fixed

Thanks @mlsamuelson, committed. I also added the hook definition to registration.api.php.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Mis-identified the hook in my original post.

  • levelos committed 100c413 on 7.x-1.x, panels, any-entity, slots, integrations, hold_state
    #1904412: Provide hook_registration_event_count_alter() so developers...
colincalnan’s picture

Issue summary: View changes

Could someone post an example of implementing their alter(). I'm trying to get this working, but the count value is not making it back to the original count function.

mlsamuelson’s picture

@colincalnan

So... in Entity Registration, the alter is invoked like so:
drupal_alter('registration_event_count', $count, $context);

With a drupal_alter(), the second and third arguments are passed by reference, meaning any assignments you make to those values won't need to be returned - they'll automatically be felt in the code calling the drupal_alter().

You could implement your own alter by dropping the following into your module (where the name of your module is "mymodule"):

function mymodule_registration_event_count_alter($count, $context) {
  $count = $count + 5; // No need to return. Will automatically be felt by the code implementing the drupal_alter().
}