0

I create an event. I need to create an API for Event Participate(Registration) page. I also retrieve all participates users data via API too. Please let me know . I just go API v3 . And see there is Event in Entity fields. I choose it. I choose get .I see there is return form too.I need all participates information . what their address,nationality and some customs fields too. I see there is create function but I don't know how can I add fields.please let know.

1 Answer 1

2

Md Maidul Islam,

Bit difficult to understand from your question what you want to achieve.

1 - Do you mean to add participant for an event? Then you can use Entity = Participant and Action = Create api

$result = civicrm_api3('Participant', 'create', [
  'event_id' => 3,
  'contact_id' => 51,
]);

2 - Do you mean to add participant for an event with all contact details in one call ? Then you can use Entity = Contact and Action = Create chain api

$params = [
    'display_name' => 'batman',
    'contact_type' => 'Individual',
    'api.address.create' => [
      'contact_id' => '$value.id',
      'location_type_id' => 6,
      'street_name' => 'Ambachtstraat',
      'street_number' => '23',
      'street_address' => 'Ambachtstraat 23',
      'postal_code' => '6971 BN',
      'country_id' => '1152',
      'city' => 'Brummen',
      'is_primary' => 1,
    ],
    'api.email.create' => [
      'contact_id' => '$value.id',
      'location_type_id' => 'Main',
      'email' => '[email protected]',
      'is_primary' => 1,
    ],
    'api.phone.create' => [
      'contact_id' => '$value.id',
      'location_type_id' => 6,
      'phone' => '(123) 456-7890',
      'is_primary' => 1,
      'phone_type_id' => 1,
    ],
    'api.participant.create' => [
      'contact_id' => '$value.id',
      'event_id' => 2,
      'status_id' => 1,
      'role_id' => 1,
      'register_date' => '2007-07-21 00:00:00',
      'source' => 'Online Event Registration: API Testing',
      'custom_1' => 'custom string',
    ],
  ];
$result = civicrm_api3('Contact', 'create', $params);

3 - Do you mean to get participant of an event with all contact details in one call ?

   $params = array(
    'contact_id' => 2,
    'event_id' => 3,
    'api.contact.get' => 1,
    'api.email.get' => ['contact_id' => '$value.contact_id'],
    'api.address.get' => ['contact_id' => '$value.contact_id'],
    'api.phone.get' => ['contact_id' => '$value.contact_id'],
  );

HTH

Pradeep

Note: The params build above are not tested, but its the syntax on how one can build params when using chain api.

HTH

Pradeep

1
  • I will try and let you know. Is there any tutorials blogs or youtube regarding that. Please let me know. Commented Apr 3, 2019 at 6:51

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.