Correct way to alter count_towards_limit
kidrobot - October 19, 2009 - 22:33
| Project: | Signup |
| Version: | 6.x-1.0-rc6 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Just wondering what is the correct way to alter count_towards_limit as not sure I understand the new hooks.
My use case is like so: I've added a new field Number of Persons to the form. When the form is saved I want to make sure the count_towards_limit is not 1 but whatever number the user entered eg. 3.
In hook_signup_data_alter, the form values are available but count_towards_limit isn't in the signup object. Is it okay to just bang a $signup->count_towards_limit = 3 in there and let signup_save_sign_up write it to the database?
Or should I use hook_signup_insert? I see that is called after the record is already written to the database so that seems too late.

#1
See #597808: Signup does not close when limit is reached -- it's a bug in RC6 that $signup->count_torwards_limit isn't set to 1 in the first place. If you try with the latest code in DRUPAL-6--1, you'll see that's how it works.
But yes, you can just stuff a $signup->count_towards_limit = 3 in there, no problem.
Cheers,
-Derek
#2
Thanks for the quick reply. Will check out 6--1 and get stuffing!
#3
I feel like I'm eavesdropping here, but could either of you clarify where "there" is? Are you talking about modifying signup.module at line 1256 (where the value of count_towards_limit is set), or making a change to signup.api.php (where the hook is)?
Kidrobot, if you've worked out how to do this and are willing to share your code changes I'd greatly appreciate seeing them (I'm a newb, obviously).
Thanks!
#4
@ln282: signup.api.php is just documentation for what hooks are invoked by signup.module and how they work. The whole point of hooks is that you implement them in other modules. So "there" is some custom module you're writing for your site, or perhaps a contributed module that extends/enhances signup in some way (there's a table of them on the signup project page, for example signup_status).
#5
Automatically closed -- issue fixed for 2 weeks with no activity.