0

I can't for the life of me store the value of is_confirmation_enabled for creating a new event via API. This is in a PHP file that creates new events on the front end of Joomla based on input collected in a 3rd party (Joomla-based) form. The event gets created just fine with all the data points as entered by the user, but the is_confirmation_enabled always ends up being "no". Tried API 3 and 4 - same results. If I try via API explorer, it works. Really lost here ... may have to resort to a SQL query to update the event record, instead, which would be a bummer. Here's my code:

$results = \Civi\Api4\Event::create(FALSE)
  ->addValue('id', '')
  ->addValue('title', $evtInfo['Title'])
  ->addValue('start_date', $evtInfo['StartDate'])
  ->addValue('end_date', $evtInfo['EndDate'])
  ->addValue('event_type_id', $evtInfo['Type'])
  ->addValue('Additional_Event_Info.Pace', $evtInfo['Pace'])
  ->addValue('Additional_Event_Info.Trail_Page', $evtInfo['TrailPage'])
  ->addValue('is_online_registration', $evtInfo['Registration'])
  ->addValue('Additional_Event_Info.Chapter', $evtInfo['Chapter'])
  ->addValue('description', $evtInfo['Description'])
  ->addValue('is_active', $evtInfo['Status'])
  ->addValue('is_public', TRUE)
  ->addValue('default_role_id', 1)
  ->addValue('is_template', FALSE)
  ->addValue('template_title', '')
  ->addValue('is_share', FALSE)
  ->addValue('is_confirm_enabled', TRUE)
  ->addValue('is_email_confirm', TRUE)
  ->addValue('confirm_email_text', 'Thank you for registering for Evergreen MTB event - please see the details below.\r\n\r\n-Evergreen MTB')
  ->addValue('confirm_from_email', '[email protected]')
  ->addValue('confirm_from_name', 'Evergreen MTB Events')
  ->execute();

Thank you for any pointers.

3
  • Can you try in the API explorer to see if you get the same results?
    – Lars SG
    Sep 10, 2023 at 18:26
  • Try removing the line ->addValue('id', '') that's kinda weird
    – Coleman
    Sep 10, 2023 at 18:40
  • As mentioned in the question, it works via API explorer; removing ->addValue('id', '') didn't do anything ... thanks for the suggestions, guys
    – MtnPavlas
    Sep 10, 2023 at 21:42

1 Answer 1

1

As humiliating as it is, I want to post an answer to keep the suggestions in the comments and to perhaps give someone a hint who may make a similar mistake to mine. I had another line of code later in the file changing the is_confirm_enabled value to "0" ... yup, I did say humiliating. Cheers.

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.