1
votes

I'm working on a registration system where someone can enter the number of participants they will be bringing in a CCK field. I want to, whenever a node type with that CCK field is added, grab the value of that field, then add it to a variable value I have in my variables table.

Is the CCK value inserted into the field's table in the db prior to my custom module running something when $op is "insert" for hook_nodeapi? Or is there some other way to directly grab the value of that field?

2
I don't fully understand you. If you're in hook_nodeapi > insert, you should have access to the values in the submitted form, and at that point can write a query (or use variable_get/set) to update your table. - sprugman
I was originally going to do that, but finally decided to use Rules. Rules is pretty powerful! - geerlingguy
I was just about to research all of this, when I saw you mention rules. That's all I need to hear. - Matt

2 Answers

1
votes

Here's how I solved this: I used the Rules module, and set up a ruleset to update the number of reserved registration spots by SUM-ing the CCK field containing each group's number reserved. Then I created rules for node additions, updates, and deletions, so the number auto-updates at all times.

It was much easier than using hook_nodeapi, and will be much easier to maintain...

0
votes

yes, hook_nodeapi. But it's not good way to save users data to variables data (each new user add new row for variables). Just keep it in cck fields.