LoginSignup
0
0

More than 3 years have passed since last update.

[WP]記事のcsv登録時にタイマーイベントを付加する

Posted at

備忘録系。

  • 指定の日に記事を下げる(時間は固定)
  • 時間はACFでフィールド入力(close_date)
function my_csv_importer_save_post( $post_object ) {
  $pid = $post_object->ID;
  $close_date = get_post_meta($pid, 'close_date', true);
  $close_date_time = $close_date . ' 23:59:59';
  if ($close_date_time != '' && date_i18n('Y-m-d H:i:s') < $close_date_time) {
    $time_stamp = strtotime($close_date_time . ' JST');
    wp_schedule_single_event($time_stamp, 'my_new_event', array($pid));
  }
}
add_action('really_simple_csv_importer_post_saved','my_csv_importer_save_post',10);

登録時にイベント付加っていうフックがwikiとかに書いてなくて
プラグインファイルみまくって、really_simple_csv_importer_post_savedを見つけた・・・

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0