tags:

views:

740

answers:

2

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?

A: 

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.

Nikit
It sounds to me like he's keeping a running total of registrants or something. If he's adding to some other table, or a value in the variable table with the value of a cck field, he could just be updating a single value every time.
sprugman
i think, it for storing some other value. Count of users easy take from via querying users table. For asker: be clear...
Nikit
sprugman had it right - I was trying to keep a total of registrants, and to get that, I wanted to allow users to give an arbitrary number of registrants per group.
geerlingguy
Count of registrants? select count(*) from users? For why when this field?
Nikit
It's not a listing of individual registrants, but a group system, where individuals can reserve an arbitrary number of spots (thus the field).
geerlingguy
+1  A: 

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...

geerlingguy

related questions