Answers.Body: <p>I am not if there is any but it's an easy one to develop via an extension or MySQL event or running MySQL via cron job.</p>
  <p><strong>MySQL query via cron job</strong></p>
  <p>using <a href="https://stackoverflow.com/questions/21196613/run-a-mysql-query-as-a-cron-job">https://stackoverflow.com/questions/21196613/run-a-mysql-query-as-a-cron-job</a></p>
  <pre><code>UPDATE civicrm_event 
  SET is_active = 0
  WHERE end_date IS NOT NULL
    AND  DATE_ADD(end_date, INTERVAL 2 DAY) &lt; now()
    AND is_active = 1;
  </code></pre>
  <p><strong>Mysql Event that will run everyday at 1:00 am</strong></p>
  <pre><code>CREATE EVENT disable_civicrm_events
    ON SCHEDULE
      EVERY 1 DAY
      STARTS (TIMESTAMP(CURRENT_DATE) + INTERVAL 1 DAY + INTERVAL 1 HOUR)
    DO
    UPDATE civicrm_event 
    SET is_active = 0
    WHERE end_date IS NOT NULL
      AND  DATE_ADD(end_date, INTERVAL 2 DAY) &lt; now()
      AND is_active = 1;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-22T21:40:53.943Z
Answers.LastActivityDate: 2022-03-22T21:40:53.943Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Is there a setting/scheduled job/something else, that can automatically set events in the state of inactive automatically after the event has ended?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-23T00:30:42.547Z
Comments.Text: what is the problem you are trying to resolve?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-23T06:02:34.313Z
Comments.Text: @petednz-fuzion we have a setup with displaying events on our website through a proxy setup, that means no direct use of native CiviEvent functionality. This setup checks for the state of the event. If the state is disabled, it will no konger be displayed, using the same logic as for relationships that gets automatically disabled after a scheduled job
Comments.UserDisplayName: Flying
Tags: <civievent>
Title: Disable active events
ThreadText: # Disable active events
  
  (Asked by: username_0 on 2022-03-22)
  
  Is there a setting/scheduled job/something else, that can automatically set events in the state of inactive automatically after the event has ended?
  
  **Tags:** civievent
  
  > **Comments:**
  > **username_1**: what is the problem you are trying to resolve?  
  > **username_0**: @petednz-fuzion we have a setup with displaying events on our website through a proxy setup, that means no direct use of native CiviEvent functionality. This setup checks for the state of the event. If the state is disabled, it will no konger be displayed, using the same logic as for relationships that gets automatically disabled after a scheduled job  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-03-22. Score: 1
  
  I am not if there is any but it's an easy one to develop via an extension or MySQL event or running MySQL via cron job.
  MySQL query via cron job
  using https://stackoverflow.com/questions/21196613/run-a-mysql-query-as-a-cron-job
  UPDATE civicrm_event 
  SET is_active = 0
  WHERE end_date IS NOT NULL
    AND  DATE_ADD(end_date, INTERVAL 2 DAY) < now()
    AND is_active = 1;
  
  Mysql Event that will run everyday at 1:00 am
  CREATE EVENT disable_civicrm_events
    ON SCHEDULE
      EVERY 1 DAY
      STARTS (TIMESTAMP(CURRENT_DATE) + INTERVAL 1 DAY + INTERVAL 1 HOUR)
    DO
    UPDATE civicrm_event 
    SET is_active = 0
    WHERE end_date IS NOT NULL
      AND  DATE_ADD(end_date, INTERVAL 2 DAY) < now()
      AND is_active = 1;
  
  
  ---
  
  