format('%R%a'); } /* * returns true if date is in paste or is empty * */ function is_card_date_expired_CIPF($user_id = null) { PLGNTLS_class::debug_infos(); /* * define user_id * */ if (is_null($user_id)) { $user_id = get_current_user_id(); } /* * check if expired * */ $date_diff = card_date_diff_CIPF($user_id); if ($date_diff === false) { return true; } else if ($date_diff < 0) { return true; } return false; } function update_card_expiration_CIPF($user_id = null, $card_duration = '0') { PLGNTLS_class::debug_infos(); $acf_card_expiration = PLGNTLS_class::ACF_CARD_EXPIRATION; /* * define acf id and acf date format * */ if (is_null($user_id)) { $user_id = get_current_user_id(); } $acf_id = 'user_'.$user_id; $acf_date_format = 'Y-m-d H:i:s'; /* * get date limit as DateTime object * */ $current_date_limit = get_date_limit_CIPF(); if ($current_date_limit === false) { return false; } /* * update date limit validity to add 1 year * */ $date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration)); update_field($acf_card_expiration['_name'], $date_plus_one_year->format($acf_date_format), $acf_id); } ?>