回答編集履歴
4
追記
answer
CHANGED
@@ -8,4 +8,30 @@
|
|
8
8
|
add_filter( 'mwform_custom_mail_tag', 'add_sender_info', 10, 3 );
|
9
9
|
```
|
10
10
|
と、思ったけど保存が最後だとエラーになるかな?
|
11
|
-
試してみてください。
|
11
|
+
試してみてください。
|
12
|
+
|
13
|
+
|
14
|
+
### **追記**
|
15
|
+
管理者、送信者にメールを送信してから保存していると思うので、やはりデータべースから何かを取るのは無理がありましたね。送信直前に保存して取り出すのも間に合わないようなので以下のような方法が最善かなぁと思います。
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
function my_mwform_session( $form_key ) {
|
20
|
+
$org_timezone = date_default_timezone_get();
|
21
|
+
date_default_timezone_set('Asia/Tokyo'); //タイムゾーンを日本に
|
22
|
+
$dtStr = date("ymdHis") . "" . substr(explode(".", microtime(true))[1], 0, 3);
|
23
|
+
date_default_timezone_set($org_timezone); //タイムゾーン戻す
|
24
|
+
if( ! isset( $_SESSION ) ){
|
25
|
+
session_start();
|
26
|
+
}
|
27
|
+
$_SESSION['TIMESTAMP'] = $dtStr;
|
28
|
+
}
|
29
|
+
add_action( 'mwform_after_exec_shortcode', 'my_mwform_session' );
|
30
|
+
function add_sender_info( $value, $key, $insert_contact_data_id ) {
|
31
|
+
if ( $key === 'timestamp' ) {
|
32
|
+
return $_SESSION['TIMESTAMP'];
|
33
|
+
}
|
34
|
+
return $value;
|
35
|
+
}
|
36
|
+
add_filter( 'mwform_custom_mail_tag', 'add_sender_info', 10, 3 );
|
37
|
+
```
|
3
追記
answer
CHANGED
@@ -6,4 +6,6 @@
|
|
6
6
|
}
|
7
7
|
}
|
8
8
|
add_filter( 'mwform_custom_mail_tag', 'add_sender_info', 10, 3 );
|
9
|
-
```
|
9
|
+
```
|
10
|
+
と、思ったけど保存が最後だとエラーになるかな?
|
11
|
+
試してみてください。
|
2
修正
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
```
|
3
3
|
function add_sender_info( $value, $key, $insert_contact_data_id ) {
|
4
4
|
if ( $key === 'timestamp' ) {
|
5
|
-
return date( '
|
5
|
+
return date( 'ymdHis', strtotime( get_post( $insert_contact_data_id )->post_date) );
|
6
6
|
}
|
7
7
|
}
|
8
8
|
add_filter( 'mwform_custom_mail_tag', 'add_sender_info', 10, 3 );
|
1
訂正
answer
CHANGED
@@ -1,16 +1,9 @@
|
|
1
|
-
こ
|
1
|
+
やっぱりこっちの方が確実ですね。
|
2
2
|
```
|
3
3
|
function add_sender_info( $value, $key, $insert_contact_data_id ) {
|
4
|
-
|
4
|
+
if ( $key === 'timestamp' ) {
|
5
|
-
$org_timezone = date_default_timezone_get();
|
6
|
-
date_default_timezone_set('Asia/Tokyo'); //タイムゾーンを日本に
|
7
|
-
$dtStr = date("ymdHi") . "" . substr(explode(".", microtime(true))[1], 0, 3);
|
8
|
-
date_default_timezone_set($org_timezone); //タイムゾーン戻す
|
9
|
-
|
5
|
+
return date( 'YmdHis', strtotime( get_post( $insert_contact_data_id )->post_date) );
|
10
|
-
|
6
|
+
}
|
11
|
-
|
12
|
-
return $value;
|
13
|
-
|
14
7
|
}
|
15
8
|
add_filter( 'mwform_custom_mail_tag', 'add_sender_info', 10, 3 );
|
16
9
|
```
|