質問編集履歴

1

自分で調べた範囲を追記しました

2017/08/28 03:41

投稿

taaa
taaa

スコア32

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,39 @@
17
17
 
18
18
 
19
19
  ご回答、どうぞよろしくお願いします
20
+
21
+
22
+
23
+
24
+
25
+ 現状まで、自分で調べた範囲のことは以下のとおりです
26
+
27
+ ======
28
+
29
+ 1)デフォルトのコメントフィールド(name,email)の入力チェックは /wp-include/comment.php のwp_handle_comment_submission()で処理されている
30
+
31
+
32
+
33
+ 2)テーマ内のfunction.phpで以下のようにした場合、1の処理のあとに実行される
34
+
35
+ add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
36
+
37
+ function verify_comment_meta_data( $commentdata ) {
38
+
39
+ if ( empty( $_POST['additional_field'] ) )
40
+
41
+ wp_die( __( 'Error: please fill the required field (additional_field).' ) );
42
+
43
+ return $commentdata;
44
+
45
+ }
46
+
47
+
48
+
49
+ 3)気持ち悪いから1と2を同時にしたいのですが、wp_handle_comment_submission()の処理前のタイミングで実行できるフィルターフックや方法はないのでしょうか
50
+
51
+ (wp-include/comment.phpを直接編集する方法は取りたくない)
52
+
53
+
54
+
55
+ ない場合、結局コメントのsubmitを捕捉してjsを使った処理をするしかないのでしょうか