簡體   English   中英

如何更改計數器以返回日期

[英]How can I change the counter to return the date

您能告訴我如何生成以下腳本嗎:2015000001 2015000002

代替:1 2 3

它還應該認識到自己應該使用的年份。 因此,例如明年將更改為2016年。

 //Define the key to store in the database
 define( 'CF7_COUNTER', 'cf7-counter' );

 //Create the shortcode which will set the value for the DTX field
 function cf7dtx_counter(){
     $val = get_option( CF7_COUNTER, 0) + 1;  //Increment the current count
     return $val;
  }
  add_shortcode('CF7_counter', 'cf7dtx_counter');

  //Action performed when the mail is actually sent by CF7
  function cf7dtx_increment_mail_counter(){
      $val = get_option( CF7_COUNTER, 0) + 1; //Increment the current count
      update_option(CF7_COUNTER, $val); //Update the settings with the new count
  }
  add_action('wpcf7_mail_sent', 'cf7dtx_increment_mail_counter');

感謝您的幫助!

安姆羅

嘗試如下。 只需添加date功能。

  $value = ("Y-m-d");

        //Create the shortcode which will set the value for the DTX field
         function cf7dtx_counter(){
         $val = get_option( CF7_COUNTER, 0) + 1;  //Increment the current count
$tmp = $value.$val;
         return  $tmp:
          }
          add_shortcode('CF7_counter', 'cf7dtx_counter');

          //Action performed when the mail is actually sent by CF7
          function cf7dtx_increment_mail_counter(){
          $val = get_option( CF7_COUNTER, 0) + 1; //Increment the current count
$tmp = $value.$val;
          update_option(CF7_COUNTER,  $tmp); //Update the settings with the new count
           }
           add_action('wpcf7_mail_sent', 'cf7dtx_increment_mail_counter');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM