WordPressでs2memberを使用しています。
7 月 31 日に固定 EOT (End of Term) を設定しました。
これが私が使用しているコーディングです..
<?php
$now = strtotime("now");
$fixed_time = strtotime("31 July 2013");
$days_until_fixed_time = round(($fixed_time - $now) / ($seconds_in_one_day = $86400));
?>
[s2member-Pro-PayPal-Form... tp="<?php echo $days_until_fixed_time; ?>" tt="D" ... /]
EOT の日付を 2013 年 7 月 31 日に設定すると、コードは正常に動作します。
ただし、日付に従って自動生成するには年が必要です。
ユーザーが7 月 31 日より前に登録した場合、EOT 年は現在の年のままにする必要があります。
ユーザーが 7 月 31 日以降に
登録した場合、EOT 年は翌年 (2014 年) に設定する必要があります。
そして、これは毎年変更しなくても機能します。
これが理にかなっていることを願っています!ご協力ありがとうございました!
編集済み
これは機能します...
<?php
$now = strtotime("now");
$fixed_time = strtotime("31 July " . date("Y"));
if($now > $fixed_time)
$fixed_time = strtotime("+1 year", $fixed_time);
$days_until_fixed_time = round(($fixed_time - $now) / ($seconds_in_one_day = $86400));
?>
[s2member-Pro-PayPal-Form... tp="<?php echo $days_until_fixed_time; ?>" tt="D" ... /]
編集#2 は今このコードを持っています..
<?php
$now = strtotime("now");
$mmdd = (int)date("M d");
$yyyy = (int)date("Y");
if ($mmdd <= 731)
$fixed_time = strtotime("31 July " . $yyyy);
else
$fixed_time = strtotime("31 July " . ($yyyy+1));
$days_until_fixed_time = round(($fixed_time - $now) / ($seconds_in_one_day = "86400"));
[s2member-Pro-PayPal-Form... tp="<?php echo $days_until_fixed_time; ?>" tt="D" ... /]
?>
問題は...
a) EOT の日付が 7 月 30 日になるのを修正しました。
b) ユーザーが日付の後に登録すると、値が 1 以上である必要があるというエラーがページに表示されます..
「フォーム構成が無効です。「tp」属性が無効です。試用期間。 1.」
まだ助けが必要..
=============== 解決策 ================
動くモデルを考え出した! みんなの助けに感謝します!
<?php
$now = strtotime("now");
$fixed_time = strtotime("31 July " . date("Y"));
if($now > $fixed_time)
$fixed_time = strtotime("+1 year", $fixed_time);
$days_until_fixed_time = round(($fixed_time - $now) / (86400));
?>
[s2member-Pro-PayPal-Form... tp="<?php echo $days_until_fixed_time; ?>" tt="D" ... /]
この構造は、EOT 日付として 7 月 31 日を正常に実装します。ユーザーが 7 月 31 日より前に登録すると、現在の年が設定されます。7月31日以降に登録すると翌年が設定されます。