Forked from jackrabbithanna/gist:295ee250ea702f2bd18c62dc587bfd4d
Created
May 11, 2022 06:14
-
-
Save UshaMakoa/1842b8b0410f8a8fd1de44e2cc920e44 to your computer and use it in GitHub Desktop.
civicrm_customs.module -- D7 Custom VBO action to update participant status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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