I have this code in my custom plugin. It's supposed to check if a timestamp is older than 24 hours
$today = new DateTime();
foreach( $customers_to_activate as $customer_details ){
$time = $customer_details['approved_date']; //this is a timestamp stored into usermeta
$registration_date = new DateTime("@$time"); //converting the timestamp into a DateTime object
$interval = $today->diff($registration_date); //checking if the timestamp is older than 24 hours
if( $interval->days > 1 && empty($customer_details['last_password_reset']) && !(bool)$customer_details['account_details_sent'] || empty($customer_details['account_details_sent']) ){ //code stuff here }
}
I've noticed that the check will not occur correctly and a test account I've registered today will get an email from my wordpress system before 24hours are elasped. Is there something wrong into the code?
$customers_to_activate
may be an empty array ornull
and it's unclear where it comes from.