Answers.Body: <p>I think you have to delete the event participants from the event before deleting the event, note that this only deletes the participants from the event and not from the db. Go to Events, find participants, select the event -> search, select all and use the action menu to delete participants. After that you can go to Events->Manage events, search and from the more link you can delete the event</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T17:54:34.447Z
Answers.LastActivityDate: 2015-07-30T17:54:34.447Z
Answers.UserDisplayName: Kboy
Answers.Body: <p>You can delete participants from an event using:</p>
  
  <pre><code>civicrm_api3('Participant', 'delete', array(
    'event_id' =&gt; $v,
    'options' =&gt; array('match' =&gt; 'event_id')
  ));
  </code></pre>
  
  <p>Once that's done you can proceed to delete the event.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T18:07:25.870Z
Answers.LastActivityDate: 2015-07-30T18:07:25.870Z
Answers.UserDisplayName: Coleman
Body: <p>I am trying to delete an event that has participants registered using:</p>
  
  <pre><code>civicrm_api( 'event','delete', array('version' =&gt; 3, 'id' =&gt; $v) );
  </code></pre>
  
  <p>Which gives an error saying that I can't delete it because it has participants.</p>
  
  <p>Is there any way to force the deletion of the event? Or how do I remove all participants of the event?</p>
  
Tags: <civievent><api>
Title: programatically delete an event that has participants
ThreadText: # programatically delete an event that has participants
  
  (Asked by: username_0 on 2015-07-30)
  
  I am trying to delete an event that has participants registered using:
  civicrm_api( 'event','delete', array('version' => 3, 'id' => $v) );
  
  Which gives an error saying that I can't delete it because it has participants.
  Is there any way to force the deletion of the event? Or how do I remove all participants of the event?
  
  **Tags:** civievent, api
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-07-30. Score: 4 | Accepted answer
  
  You can delete participants from an event using:
  civicrm_api3('Participant', 'delete', array(
    'event_id' => $v,
    'options' => array('match' => 'event_id')
  ));
  
  Once that's done you can proceed to delete the event.
  
  
  ---
  
  ### Answer by username_1 on 2015-07-30. Score: 1
  
  I think you have to delete the event participants from the event before deleting the event, note that this only deletes the participants from the event and not from the db. Go to Events, find participants, select the event -> search, select all and use the action menu to delete participants. After that you can go to Events->Manage events, search and from the more link you can delete the event
  
  
  ---
  
  