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