0

Is there a setting/scheduled job/something else, that can automatically set events in the state of inactive automatically after the event has ended?

2
  • what is the problem you are trying to resolve?
    – petednz - fuzion
    Mar 23, 2022 at 0:30
  • 1
    @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
    – Flying
    Mar 23, 2022 at 6:02

1 Answer 1

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;

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.