$result1 = civicrm_api3('Participant', 'create', [
        'id' => $participant_id,
        'contact_id' => $contact_id,
        'event_id'   => $event_id,
        'status_id' => "Registered",//已登記

when I have English enabled in the civicrm, the above API works changes
status to Registered from Attended
When I have Chinese Language enabled in the civicrm, the above API does not change the status
In the list of Civicrm Participant Status I found that Participant
status label is different in Chinese and English(which is obvious)
But how can we determine if the civicrm page is chinese, As I am using
drupal, In drupal we have

global $language;
$lang_code = $language->language;

but in civicrm , how can we determine the language selected from the
dropdown and based on that change status_id to be in chinese.

1 Answer 1


Even if the label is different in English and Chinese, the above API with 'status_id' => "Registered", parameter should work fine as it is meant to make the mapping based on name and not label.

Anyway, I think you should be able to use id instead of passing the name of the participant status in the api params. Something like -

$statusOptions = CRM_Event_BAO_Participant::buildOptions('status_id', 'validate');
...your api ...
  'status_id' => array_search('Registered', $statusOptions),

If the above fails, and you still want to do this by knowing which language is enabled, you can simply use -

$currentLanguageLocale = CRM_Core_I18n::getLocale();

The variable $currentLanguageLocale will hold the locale value of the current language enabled in civi.

  • Can you elaborate on how to get status_id and use it in Participant Api clearly using above quoted code in the question?
    – harshal
    Commented Mar 19, 2019 at 6:03
  • Have already done that. array_search('Registered', $statusOptions) will provide you the id of Registered participant status. Commented Mar 19, 2019 at 6:10
  • Can I write a custom query to update the Participant Status UPDATE civicrm_participant SET status_id = '1' WHERE civicrm_participant.id = 1; will that be work or its a bad idea? and if yes how can I write a custom query in civicrm? @jitendra ?
    – harshal
    Commented Mar 19, 2019 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.