Answers.Body: <p>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 &quot;0&quot; ... yup, I did say humiliating. Cheers.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-19T12:08:34.467Z
Answers.LastActivityDate: 2023-09-19T12:08:34.467Z
Answers.UserDisplayName: MtnPavlas
Body: <p>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 &quot;no&quot;. 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:</p>
  <pre><code>$results = \Civi\Api4\Event::create(FALSE)
    -&gt;addValue('id', '')
    -&gt;addValue('title', $evtInfo['Title'])
    -&gt;addValue('start_date', $evtInfo['StartDate'])
    -&gt;addValue('end_date', $evtInfo['EndDate'])
    -&gt;addValue('event_type_id', $evtInfo['Type'])
    -&gt;addValue('Additional_Event_Info.Pace', $evtInfo['Pace'])
    -&gt;addValue('Additional_Event_Info.Trail_Page', $evtInfo['TrailPage'])
    -&gt;addValue('is_online_registration', $evtInfo['Registration'])
    -&gt;addValue('Additional_Event_Info.Chapter', $evtInfo['Chapter'])
    -&gt;addValue('description', $evtInfo['Description'])
    -&gt;addValue('is_active', $evtInfo['Status'])
    -&gt;addValue('is_public', TRUE)
    -&gt;addValue('default_role_id', 1)
    -&gt;addValue('is_template', FALSE)
    -&gt;addValue('template_title', '')
    -&gt;addValue('is_share', FALSE)
    -&gt;addValue('is_confirm_enabled', TRUE)
    -&gt;addValue('is_email_confirm', TRUE)
    -&gt;addValue('confirm_email_text', 'Thank you for registering for Evergreen MTB event - please see the details below.\r\n\r\n-Evergreen MTB')
    -&gt;addValue('confirm_from_email', 'events@evergreenmtb.org')
    -&gt;addValue('confirm_from_name', 'Evergreen MTB Events')
    -&gt;execute();
  </code></pre>
  <p>Thank you for any pointers.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-10T18:26:58.427Z
Comments.Text: Can you try in the API explorer to see if you get the same results?
Comments.UserDisplayName: Lars SG
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-10T18:40:08.687Z
Comments.Text: Try removing the line `->addValue('id', '')` that's kinda weird
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-10T21:42:02.373Z
Comments.Text: As mentioned in the question, it works via API explorer; removing ->addValue('id', '') didn't do anything ... thanks for the suggestions, guys
Comments.UserDisplayName: MtnPavlas
Tags: <civievent><api><apiv4>
Title: Can't store is_confirmation_enabled via API
ThreadText: # Can't store is_confirmation_enabled via API
  
  (Asked by: username_0 on 2023-09-10)
  
  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', 'events@evergreenmtb.org')
    ->addValue('confirm_from_name', 'Evergreen MTB Events')
    ->execute();
  
  ```
  
  Thank you for any pointers.
  
  **Tags:** civievent, api, apiv4
  
  > **Comments:**
  > **username_1**: Can you try in the API explorer to see if you get the same results?  
  > **username_2**: Try removing the line `->addValue('id', '')` that's kinda weird  
  > **username_0**: As mentioned in the question, it works via API explorer; removing ->addValue('id', '') didn't do anything ... thanks for the suggestions, guys  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-09-19. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  