How do I set the event capacity?
Ideally, I would like users to be able to enter a number "number of attendees" and have his count against the total event capacity.
Also, how do I display the total number of attendees signed up for an event?

Comments

Pene’s picture

Go to /admin/structure/types/manage/event/fields and there you have to set up a new variable (type: number, widget type: text). My variable's full name for the system is field_event_capacity (important for the below section). If you need it, use mandatory variable.

There you go, a displaying method:

If you are user #1: Get Views PHP module, install, enable.
Go in to your calendar, week etc. view.
Add a PHP field into Fields part.
To the Output code section, insert something like this:

$nodeidd=$data->nid;
$query = db_select('field_data_field_event_capacity', 'fec');
$query
    ->fields('fec', array('field_event_capacity_value'))
    ->condition('fec.entity_id', $nodeidd);
$capacity = $query->execute()->fetchField();
/* Now $capacity is your full capacity of the event. */
$query2= db_select('field_data_field_event_signup', 'fes');
$query2->fields('fes', array('entity_id'))
    ->condition('fes.field_event_signup_nid', $nodeidd);
$signedup=$query2->countQuery()->execute()->fetchField();
/* Now $signedup is the total number of your attendees on your event. Important, if your signup has got different name, change the field_data_field_event_signup variable everywhere. */
echo $signedup." / ".$capacity;
/* Prints (echoes) your desired numbers. */