質問編集履歴
3
文章追加修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
|
9
9
|
メールの内容を変更したく
|
10
10
|
|
11
|
-
下記のコード
|
11
|
+
下記のコードをfunctions.phpに
|
12
|
-
|
12
|
+
|
13
|
-
書いたのですのが
|
13
|
+
書いたのですのが表示が
|
14
|
-
|
14
|
+
|
15
|
-
変わりませんでした。
|
15
|
+
変わることがありませんでした。
|
16
16
|
|
17
17
|
|
18
18
|
|
@@ -68,6 +68,10 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
71
75
|
試したコード
|
72
76
|
|
73
77
|
---
|
@@ -317,3 +321,35 @@
|
|
317
321
|
add_filter( 'comment_moderation_text', 'custom_comment_moderation_text', 10, 2 );
|
318
322
|
|
319
323
|
```
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
こうなると思った
|
330
|
+
|
331
|
+
---
|
332
|
+
|
333
|
+
「◯◯◯◯」にコメントがありました。確認をお願いします。
|
334
|
+
|
335
|
+
http://◯◯◯◯◯
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
========================================
|
340
|
+
|
341
|
+
投稿者:◯◯◯◯◯
|
342
|
+
|
343
|
+
IP:000.0000.0000.0
|
344
|
+
|
345
|
+
メールアドレス:◯◯◯◯◯@◯◯◯◯◯
|
346
|
+
|
347
|
+
URL:http://◯◯◯◯◯
|
348
|
+
|
349
|
+
コメント:
|
350
|
+
|
351
|
+
◯◯◯◯◯
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
========================================
|
2
文章修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
wpでコメント
|
1
|
+
wpでコメントの受信時にメールの内容を変更したい
|
test
CHANGED
@@ -6,17 +6,17 @@
|
|
6
6
|
|
7
7
|
入れると下記のメールがとどきました。
|
8
8
|
|
9
|
-
問題なのが「IPアドレス」と相手の「メールアドレス」です。
|
10
|
-
|
11
|
-
この個人情報を表示させたくないと思うのですが、
|
12
|
-
|
13
|
-
あと、「パーマリンク」「ゴミ箱に移動する」「スパムとしてマークする」も
|
14
|
-
|
15
|
-
|
9
|
+
メールの内容を変更したく
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
|
19
|
-
|
11
|
+
下記のコードでfunctions.phpに
|
12
|
+
|
13
|
+
書いたのですのが特に表示が
|
14
|
+
|
15
|
+
変わりませんでした。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
何が原因なのでしょうか。
|
20
20
|
|
21
21
|
ご教授お願いします。
|
22
22
|
|
@@ -28,6 +28,8 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
メール内容
|
32
|
+
|
31
33
|
---
|
32
34
|
|
33
35
|
宛先:nihon@japan.site
|
@@ -61,3 +63,257 @@
|
|
61
63
|
ゴミ箱に移動する: http://◯◯◯◯◯◯.net
|
62
64
|
|
63
65
|
スパムとしてマークする: http://◯◯◯◯◯◯.net
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
試したコード
|
72
|
+
|
73
|
+
---
|
74
|
+
|
75
|
+
```php
|
76
|
+
|
77
|
+
/**
|
78
|
+
|
79
|
+
* コメント確認メールの件名を変更します。
|
80
|
+
|
81
|
+
*/
|
82
|
+
|
83
|
+
function custom_comment_moderation_subject( $subject, $comment_id ) {
|
84
|
+
|
85
|
+
// ブログ名(サイト名)
|
86
|
+
|
87
|
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
88
|
+
|
89
|
+
// コメント
|
90
|
+
|
91
|
+
$comment = get_comment($comment_id);
|
92
|
+
|
93
|
+
// 投稿
|
94
|
+
|
95
|
+
$post = get_post($comment->comment_post_ID);
|
96
|
+
|
97
|
+
// トラックバック、ピンバック、コメントそれぞれで件名を変更
|
98
|
+
|
99
|
+
switch ( $comment->comment_type ) {
|
100
|
+
|
101
|
+
case 'trackback': // トラックバック
|
102
|
+
|
103
|
+
return "[{$blogname}] 「{$post->post_title}」にトラックバックがありました";
|
104
|
+
|
105
|
+
case 'pingback': // ピンバック
|
106
|
+
|
107
|
+
return "[{$blogname}] 「{$post->post_title}」にピンバックがありました";
|
108
|
+
|
109
|
+
default: // コメント
|
110
|
+
|
111
|
+
return "[{$blogname}] 「{$post->post_title}」にコメントがありました";
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
add_filter( 'comment_moderation_subject', 'custom_comment_moderation_subject', 10, 2 );
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
/**
|
122
|
+
|
123
|
+
* コメント確認メールの本文を変更します。
|
124
|
+
|
125
|
+
*/
|
126
|
+
|
127
|
+
function custom_comment_moderation_text( $notify_message, $comment_id ) {
|
128
|
+
|
129
|
+
global $wpdb;
|
130
|
+
|
131
|
+
// コメント
|
132
|
+
|
133
|
+
$comment = get_comment($comment_id);
|
134
|
+
|
135
|
+
// コメントのあった投稿
|
136
|
+
|
137
|
+
$post = get_post($comment->comment_post_ID);
|
138
|
+
|
139
|
+
// 投稿元のドメイン名
|
140
|
+
|
141
|
+
$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
|
142
|
+
|
143
|
+
// 未承認の数を取得
|
144
|
+
|
145
|
+
$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
|
146
|
+
|
147
|
+
// ブログ名(サイト名)
|
148
|
+
|
149
|
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
150
|
+
|
151
|
+
// コメント
|
152
|
+
|
153
|
+
$comment_content = wp_specialchars_decode( $comment->comment_content );
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
// トラックバック、ピンバック、コメントそれぞれで本文を変更
|
158
|
+
|
159
|
+
switch ( $comment->comment_type ) {
|
160
|
+
|
161
|
+
case 'trackback': // トラックバック
|
162
|
+
|
163
|
+
$notify_message = "「{$post->post_title}」にトラックバックがありました。確認をお願いします。\r\n";
|
164
|
+
|
165
|
+
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
|
166
|
+
|
167
|
+
$notify_message .= "\r\n";
|
168
|
+
|
169
|
+
$notify_message .= "========================================\r\n";
|
170
|
+
|
171
|
+
$notify_message .= "\r\n";
|
172
|
+
|
173
|
+
$notify_message .= "トラックバック元: {$comment->comment_author}\r\n";
|
174
|
+
|
175
|
+
$notify_message .= "IP: {$comment->comment_author_IP} ({$comment_author_domain})\r\n";
|
176
|
+
|
177
|
+
$notify_message .= "URL: {$comment->comment_author_url}\r\n";
|
178
|
+
|
179
|
+
$notify_message .= "トラックバックの概要: \r\n";
|
180
|
+
|
181
|
+
$notify_message .= "{$comment_content}\r\n";
|
182
|
+
|
183
|
+
$notify_message .= "\r\n";
|
184
|
+
|
185
|
+
$notify_message .= "========================================\r\n";
|
186
|
+
|
187
|
+
$notify_message .= "\r\n";
|
188
|
+
|
189
|
+
break;
|
190
|
+
|
191
|
+
case 'pingback': // ピンバック
|
192
|
+
|
193
|
+
$notify_message = "「{$post->post_title}」にピンバックがありました。確認をお願いします。\r\n";
|
194
|
+
|
195
|
+
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
|
196
|
+
|
197
|
+
$notify_message .= "\r\n";
|
198
|
+
|
199
|
+
$notify_message .= "========================================\r\n";
|
200
|
+
|
201
|
+
$notify_message .= "\r\n";
|
202
|
+
|
203
|
+
$notify_message .= "ピンバック元: {$comment->comment_author}\r\n";
|
204
|
+
|
205
|
+
$notify_message .= "IP: {$comment->comment_author_IP} ({$comment_author_domain})\r\n";
|
206
|
+
|
207
|
+
$notify_message .= "URL: {$comment->comment_author_url}\r\n";
|
208
|
+
|
209
|
+
$notify_message .= "ピンバックの概要: \r\n";
|
210
|
+
|
211
|
+
$notify_message .= "{$comment_content}\r\n";
|
212
|
+
|
213
|
+
$notify_message .= "\r\n";
|
214
|
+
|
215
|
+
$notify_message .= "========================================\r\n";
|
216
|
+
|
217
|
+
$notify_message .= "\r\n";
|
218
|
+
|
219
|
+
break;
|
220
|
+
|
221
|
+
default: // コメント
|
222
|
+
|
223
|
+
$notify_message = "「{$post->post_title}」にコメントがありました。確認をお願いします。\r\n";
|
224
|
+
|
225
|
+
$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
|
226
|
+
|
227
|
+
$notify_message .= "\r\n";
|
228
|
+
|
229
|
+
$notify_message .= "========================================\r\n";
|
230
|
+
|
231
|
+
$notify_message .= "\r\n";
|
232
|
+
|
233
|
+
$notify_message .= "投稿者: {$comment->comment_author}\r\n";
|
234
|
+
|
235
|
+
$notify_message .= "IP: {$comment->comment_author_IP} ({$comment_author_domain})\r\n";
|
236
|
+
|
237
|
+
$notify_message .= "メールアドレス: {$comment->comment_author_email}\r\n";
|
238
|
+
|
239
|
+
$notify_message .= "URL: {$comment->comment_author_url}\r\n";
|
240
|
+
|
241
|
+
$notify_message .= "コメント: \r\n";
|
242
|
+
|
243
|
+
$notify_message .= "{$comment_content}\r\n";
|
244
|
+
|
245
|
+
$notify_message .= "\r\n";
|
246
|
+
|
247
|
+
$notify_message .= "========================================\r\n";
|
248
|
+
|
249
|
+
$notify_message .= "\r\n";
|
250
|
+
|
251
|
+
break;
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
// === 操作用URLの記載 ===
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
$notify_message .= "各操作は下記のアドレスから行うことができます。\r\n";
|
264
|
+
|
265
|
+
$notify_message .= "\r\n";
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
// 承認
|
270
|
+
|
271
|
+
$notify_message .= "承認: \r\n";
|
272
|
+
|
273
|
+
$notify_message .= admin_url("comment.php?action=approve&c=$comment_id") . "\r\n";
|
274
|
+
|
275
|
+
// ゴミ箱に移動
|
276
|
+
|
277
|
+
if ( EMPTY_TRASH_DAYS ) {
|
278
|
+
|
279
|
+
$notify_message .= "ゴミ箱に移動: \r\n";
|
280
|
+
|
281
|
+
$notify_message .= admin_url("comment.php?action=trash&c=$comment_id") . "\r\n";
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
// 削除
|
286
|
+
|
287
|
+
else {
|
288
|
+
|
289
|
+
$notify_message .= "削除: \r\n";
|
290
|
+
|
291
|
+
$notify_message .= admin_url("comment.php?action=delete&c=$comment_id") . "\r\n";
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
// スパムとしてマーク
|
296
|
+
|
297
|
+
$notify_message .= "スパムとしてマーク: \r\n";
|
298
|
+
|
299
|
+
$notify_message .= admin_url("comment.php?action=spam&c=$comment_id") . "\r\n";
|
300
|
+
|
301
|
+
// 未承認のコメント一覧
|
302
|
+
|
303
|
+
$notify_message .= "未承認のコメント一覧(" . number_format_i18n($comments_waiting) . "件)を見る: \r\n";
|
304
|
+
|
305
|
+
$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
// === / 操作用URLの記載 ===
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
return $notify_message;
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
add_filter( 'comment_moderation_text', 'custom_comment_moderation_text', 10, 2 );
|
318
|
+
|
319
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,6 +21,10 @@
|
|
21
21
|
ご教授お願いします。
|
22
22
|
|
23
23
|
|
24
|
+
|
25
|
+
WordPressのバージョン
|
26
|
+
|
27
|
+
WordPress 4.6.5
|
24
28
|
|
25
29
|
|
26
30
|
|