繁体   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