回答編集履歴

2

2017/10/25 09:07

投稿

退会済みユーザー
test CHANGED
@@ -5,3 +5,77 @@
5
5
  Post Status Notifier Lite
6
6
 
7
7
  [https://wordpress.org/plugins/post-status-notifier-lite/](https://wordpress.org/plugins/post-status-notifier-lite/)
8
+
9
+
10
+
11
+ **追記**
12
+
13
+ レビュー待ちの投稿がされた時に管理者にメールで通知する
14
+
15
+ http://wpcj.net/1190
16
+
17
+
18
+
19
+ 上記サイトのコードを弄って投稿者へ通知するよう変えましたが、プラグイン経由の投稿でも上手く動くのか分かりませんが試してみてください。
20
+
21
+
22
+
23
+ ```
24
+
25
+ function mail_for_pending( $new_status, $old_status, $post ) {
26
+
27
+ $user_id = $post ->post_author;
28
+
29
+ $user_info = get_userdata( $user_id );
30
+
31
+ $user_email = $user_info->user_email;
32
+
33
+
34
+
35
+ // 投稿がレビュー待ち以外からレビュー待ちに変わった(新規の場合は$old_statusが'new'、$new_statusが'pending'になります)
36
+
37
+ if ( $old_status != 'pending' && $new_status == 'pending' ) {
38
+
39
+ // ブログ名(サイト名)
40
+
41
+ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
42
+
43
+ // 投稿名
44
+
45
+ $post_title = wp_specialchars_decode($post->post_title, ENT_QUOTES);
46
+
47
+
48
+
49
+ // 送信先(管理者) ※ここを投稿者に変更
50
+
51
+ //$to = get_option('admin_email');
52
+
53
+ $to = $user_email;
54
+
55
+ // 件名
56
+
57
+ $subject = "[{$blogname}] 承認待ちの投稿が投稿されました({$post_title})";
58
+
59
+ // 本文
60
+
61
+ $message = "承認待ちの投稿「{$post_title}」が投稿されました。確認をお願いします。\r\n";
62
+
63
+ $message .= "\r\n";
64
+
65
+ $message .= "編集および公開: \r\n";
66
+
67
+ $message .= wp_specialchars_decode(get_edit_post_link( $post->ID ), ENT_QUOTES) . "\r\n";
68
+
69
+
70
+
71
+ // メールを送信
72
+
73
+ $r = wp_mail( $to, $subject, $message );
74
+
75
+ }
76
+
77
+ }
78
+
79
+ add_action( 'transition_post_status', 'mail_for_pending', 10, 3 );
80
+
81
+ ```

1

2017/10/25 09:07

投稿

退会済みユーザー
test CHANGED
@@ -4,4 +4,4 @@
4
4
 
5
5
  Post Status Notifier Lite
6
6
 
7
- [https://wordpress.org/plugins/post-status-notifier-lite](https://wordpress.org/plugins/post-status-notifier-lite)/
7
+ [https://wordpress.org/plugins/post-status-notifier-lite/](https://wordpress.org/plugins/post-status-notifier-lite/)