2014-12-02 56 views
0

我使用Wordpress S2會員Pro插件,它爲用戶提供了一個EOT(期限結束)日期。內的值設置爲時間戳的數據庫,即1417564800Wordpress php/strtotime問題

在WordPress用戶配置文件,這將顯示爲「星期三2014年12月3日上午12:00 UTC」

我已經添加了運行時的一些代碼一筆成功的付款已經完成。在代碼中,我有以下函數的頂部:

$end = strtotime('+1 years', $timestamp); 
$timestamp = $wp_s2member_auto_eot_time; 

有點在該代碼進一步下跌,我想通過拉新的日期如下:

"s2member_auto_eot_time" => "$end", 

然而,這是拉動在接下來的日期'Wed Dec 3,6000 12:00 am UTC',而不是比當前日期提前一年。

任何意見,非常感謝。

謝謝。

這裏是其條款內容的代碼段:

<?php 

$end  = mktime(date('h', $timestamp), date('i', $timestamp), date('s', $timestamp), $date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp) + 1); 
$timestamp = $wp_s2member_auto_eot_time; 

$op["op"]  = "create_user"; // The Remote Operation. 
$op["api_key"] = "f4a01f73836f0385f6996a70b372dca3"; // Check your Dashboard for this value. 
// See: `s2Member -› API/Scripting -› Remote Operations API -› API Key` 

$op["data"] = array(
     "user_login" => $my_cookie_variable["username"], // Required. A unique Username. Lowercase alphanumerics/underscores. 
     "user_email" => $my_cookie_variable["email"], // Required. A valid/unique Email Address for the new User. 

     // These additional details are 100% completely optional. 

     "modify_if_login_exists" => "1", // Optional. Update/modify if ``user_login`` value already exists in the database? 
     // A non-zero value tells s2Member to update/modify an existing account with the details you provide, if this Username already exists. 

     "user_pass" => "", // Optional. Plain text Password. If empty, this will be auto-generated. 

     "first_name" => $my_cookie_variable["first"], // Optional. First Name for the new User. 
     "last_name" => $my_cookie_variable["last"], // Optional. Last Name for the new User. 

     "s2member_level" => "2", // Optional. Defaults to Level 0 (a Free Subscriber). 
     "s2member_ccaps" => "", // Optional. Comma-delimited list of Custom Capabilities. 

     "s2member_registration_ip" => "", // Optional. User's IP Address. If empty, s2Member will fill this upon first login. 

     "s2member_subscr_gateway" => "", // Optional. User's Paid Subscr. Gateway Code. One of: (paypal|alipay|authnet|ccbill|clickbank|google). 
     "s2member_subscr_id" => "", // Optional. User's Paid Subscr. ID. For PayPal®, use their Subscription ID, or Recurring Profile ID. 

     "s2member_custom" => "www.website.com", // Optional. If provided, should always start with your installation domain name (i.e. $_SERVER["HTTP_HOST"]). 

     "s2member_auto_eot_time" => "$end", 

     "custom_fields" => array(
      "title" => $my_cookie_variable["title"], 
      "giftaid" => "No", 
      "membership_number" => "", 
      "tel" => $my_cookie_variable["telephone"], 
      "address" => $my_cookie_variable["address1"], 
      "towncity" => $my_cookie_variable["city"], 
      "county" => $my_cookie_variable["state"], 
      "postcode" => $my_cookie_variable["postcode"], 
      "country" => $my_cookie_variable["countryshort"], 
      "region" => $my_cookie_variable["region"] 
    ), // Optional. An array of Custom Registration/Profile Field ID's, with associative values. 

     "s2member_notes" => "Administrative notation. Created this User via API call.", // Optional. Administrative notations. 

     "opt_in" => "1", // Optional. A non-zero value tells s2Member to attempt to process any List Servers you've configured in the Dashboard area. 
     // This may result in your mailing list provider sending the User/Member a subscription confirmation email (i.e. ... please confirm your subscription). 

     "notification" => "1" // Optional. A non-zero value tells s2Member to email the new User/Member their Username/Password. 
     // The "notification" parameter also tells s2Member to notify the site Administrator about this new account. 
); 

$post_data = stream_context_create(array(
     "http" => array(
      "method" => "POST", 
      "header" => "Content-type: application/x-www-form-urlencoded", 
      "content" => "s2member_pro_remote_op=" . urlencode(serialize($op)) 
    ) 
)); 

$result = trim(file_get_contents("http://www.website.com/?s2member_pro_remote_op=1", false, $post_data)); 

if (!empty($result) && !preg_match("/^Error\:/i", $result) && is_array($user = @unserialize($result))) 
     echo "Payment Success - Thank you."; 
else 
     echo "API error reads: " . $result; 
?> 
+0

也許前兩行代碼互相切換?請發佈更多的代碼,因爲它很難看到發生了什麼 – 2014-12-02 16:45:34

+1

您在設置之前使用'$ timestamp' ... – ceejayoz 2014-12-02 16:49:13

回答

0

如果日期已經是Unix時間戳,爲什麼不使用轉換呢?

$time = mktime(date('h',$timestamp),date('i',$timestamp),date('s',$timestamp),$date('m',$timestamp),date('d',$timestamp),date('Y',$timestamp)+1); 
echo date('D M d, Y',$time); 
+0

感謝您的支持 - 我添加了更多的代碼,因爲它仍然不起作用。 – dmt 2014-12-02 16:58:20

0

它看起來像你試圖通過使用$ timestamp,在實際設置您的$ timestamp變量之前的行上計算出$ end值。