I’m having a problem with PHP errors for dates. I have a field so that once a user is emailed a notice about their membership, the date gets stored so they don’t get emailed again. Initially this field is empty but I’m getting a lot of errors like this:
Warning: strtotime() expects parameter 1 to be string, object given in /var/www/vhosts/domain.com/httpdocs/wp-content/plugins/advanced-custom-fields-pro/fields/date_picker.php on line 217 Warning: DateTime::createFromFormat() expects parameter 2 to be string, object given in /var/www/vhosts/domain.com/httpdocs/wp-content/themes/ddi-v1/functions-members.php on line 301
Hm. Any ACF field where no one has added any values (manually or programmatically) should just return false since they don’t even exist in the DB yet. Are you sure you haven’t got any code creating an empty value or maybe you’ve added and then deleted the date?
As for your check maybe something like this works? I assume you’re in a function that would send out an email if it keeps going.
I think the issue is I was calling get_field with the field key instead of the field name. It seems that ACF returns an empty object for this if there is no value. When I switched to the field name, I stopped getting errors.