Instead of updating the Participant,its creating new participant.I need to change participant status from registered to attended and vice versa.
civicrm_initialize();
$result = civicrm_api3('Participant', 'create', [
'id' => $entity_id,
'contact_id' => $context['civicrm_participant']->contact_id,
'event_id' => $context['civicrm_participant']->event_id,
'status_id' => "Registered",
]);
I am executing the above code in the hook_action_info() drupal 7 using views bulk operations & custom entity module
function custom_changes_action_info() {
return array(
'custom_changes_actions_participant_status_attended_action' => array(
'type' => 'civicrm_participant',
'label' => t('Change Participant Status to Attended'),
'configurable' => FALSE,
'behavior' => array('changes_property'),
'triggers' => array('any'),
),
'custom_changes_actions_participant_status_registered_action' => array(
'type' => 'civicrm_participant',
'label' => t('Change Participant Status to Registered'),
'configurable' => FALSE,
'behavior' => array('changes_property'),
'triggers' => array('any'),
),
);
}
function custom_changes_actions_participant_status_attended_action($entity, $context = array()) {
$entity_id = $entity->{$info['entity keys']['id']};
civicrm_initialize();
$result = civicrm_api3('Participant', 'create', [
'id' => $entity_id,
'contact_id' => $context['civicrm_participant']->contact_id,
'event_id' => $context['civicrm_participant']->event_id,
'status_id' => "Attended",
]);
//drupal_set_message($entity_id. 'entity_id');
// $base_url = str_replace('_', '-', $context['entity_type']); // civicrm-participant
//civicrm_entity_drupal_goto($base_url . '/' . $entity_id . '/edit');
}