Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackrabbithanna/295ee250ea702f2bd18c62dc587bfd4d to your computer and use it in GitHub Desktop.
Save jackrabbithanna/295ee250ea702f2bd18c62dc587bfd4d to your computer and use it in GitHub Desktop.
civicrm_customs.module -- D7 Custom VBO action to update participant status
function civicrm_customs_action_info() {
return array(
'civicrm_customs_update_participant_status_action' => array(
'type' => 'civicrm_participant',
'label' => t('Update participant status'),
'behavior' => array('views_property'),
'configurable' => FALSE,
'vbo_configurable' => TRUE,
'triggers' => array('any'),
'pass rows' => TRUE,
),
);
}
// The function name must be [action_name] + '_form'.
function civicrm_customs_update_participant_status_action_form($settings, &$form_state) {
civicrm_initialize();
$participant_status_options_result = civicrm_api3('Participant', 'getoptions', [
'field' => "participant_status_id",
]);
$form = array();
$form['participant_status'] = array(
'#type' => 'select',
'#title' => t('Participant Status'),
'#options' => $participant_status_options_result['values'],
'#required' => TRUE,
'#default_value' => "1",
);
return $form;
}
// The function name must be [action_name] + '_submit'.
function civicrm_customs_update_participant_status_action_submit($form, $form_state) {
$return = array();
$return['participant_status'] = $form_state['values']['participant_status'];
return $return; //Note, return value here must be an array.
}
function civicrm_customs_update_participant_status_action(&$entity, $context) {
$result = civicrm_api3('Participant', 'create', [
'id' => $entity->id,
'participant_status_id' => $context['participant_status'],
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment