getStats(); $lastLoggedIn = ( ! $stats['last_visit']) ? null : strtotime($stats['last_visit']); $creationDate = strtotime($customer->date_add); $expTime = (new DateTime('now'))->modify('-12 months')->getTimestamp(); if ($creationDate < $expTime) { if ( ! $lastLoggedIn && $stats['nb_orders'] < 1) { if ( ! $countOnly) { $customer->delete(); } $count++; } if ($lastLoggedIn && $lastLoggedIn < $expTime && $stats['nb_orders'] < 1) { if ( ! $countOnly) { $customer->delete(); } $count++; } } } if ( ! $countOnly) { $currDate = date("m-d-Y H:i:s"); file_put_contents( __DIR__ . '/history.log', $currDate . ' - ' . 'Process ended: Deleted inactive users: ' . (string)$count . PHP_EOL, FILE_APPEND ); } echo 'Process ended: Deleted or to delete inactive users: ' . (string)$count;