Filter by custom date attribute? Job to delete older pages automatically

Permalink
Hi,

I'm trying to get a job working to delete pages after a given time. The script works but it filters by date added, I need it to filter by a custom attribute I made called 'datum' which is a date attribute.

The code I used i get from this topic (credit for the maker)https://www.concrete5.org/community/forums/usage/delete-pages-after-...

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
class DashboardSystemTestdeleteController extends Controller {
   function view() {
   }
   public function test_delete() { //In single_pages, do not prepend "action_" (unlike blocks)
      $expiry = date('Y-m-d', strtotime('+1 days'));
      echo "TEST: DELETING PAGES ADDED ON OR BEFORE: {$expiry} <br />";
      Loader::model('page_list');
      $pl = new PageList();
      $pl->filterByPath('/agenda', true);
      $pl->filterByCollectionTypeID(5);
      $pl->filterByDateAdded($expiry, '<=');
      $pages = $pl->get();
      foreach ($pages as $page) {

 
hutman replied on at Permalink Reply
hutman
Just replace

$pl->filterByDateAdded($expiry, '<=');


With

$pl->filterByDateAdded('datum', $expiry, '<=');
JaPPa replied on at Permalink Reply
Got it working with
$pl->filterByDatum($expiry, '<=');