teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

2017/10/25 09:07

投稿

退会済みユーザー
answer CHANGED
@@ -1,4 +1,41 @@
1
1
  Post Status Notifier Liteを使えば、とりあえず好きなように設定できると思います。
2
2
 
3
3
  Post Status Notifier Lite
4
- [https://wordpress.org/plugins/post-status-notifier-lite/](https://wordpress.org/plugins/post-status-notifier-lite/)
4
+ [https://wordpress.org/plugins/post-status-notifier-lite/](https://wordpress.org/plugins/post-status-notifier-lite/)
5
+
6
+ **追記**
7
+ レビュー待ちの投稿がされた時に管理者にメールで通知する
8
+ http://wpcj.net/1190
9
+
10
+ 上記サイトのコードを弄って投稿者へ通知するよう変えましたが、プラグイン経由の投稿でも上手く動くのか分かりませんが試してみてください。
11
+
12
+ ```
13
+ function mail_for_pending( $new_status, $old_status, $post ) {
14
+ $user_id = $post ->post_author;
15
+ $user_info = get_userdata( $user_id );
16
+ $user_email = $user_info->user_email;
17
+
18
+ // 投稿がレビュー待ち以外からレビュー待ちに変わった(新規の場合は$old_statusが'new'、$new_statusが'pending'になります)
19
+ if ( $old_status != 'pending' && $new_status == 'pending' ) {
20
+ // ブログ名(サイト名)
21
+ $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
22
+ // 投稿名
23
+ $post_title = wp_specialchars_decode($post->post_title, ENT_QUOTES);
24
+
25
+ // 送信先(管理者) ※ここを投稿者に変更
26
+ //$to = get_option('admin_email');
27
+ $to = $user_email;
28
+ // 件名
29
+ $subject = "[{$blogname}] 承認待ちの投稿が投稿されました({$post_title})";
30
+ // 本文
31
+ $message = "承認待ちの投稿「{$post_title}」が投稿されました。確認をお願いします。\r\n";
32
+ $message .= "\r\n";
33
+ $message .= "編集および公開: \r\n";
34
+ $message .= wp_specialchars_decode(get_edit_post_link( $post->ID ), ENT_QUOTES) . "\r\n";
35
+
36
+ // メールを送信
37
+ $r = wp_mail( $to, $subject, $message );
38
+ }
39
+ }
40
+ add_action( 'transition_post_status', 'mail_for_pending', 10, 3 );
41
+ ```

1

2017/10/25 09:07

投稿

退会済みユーザー
answer CHANGED
@@ -1,4 +1,4 @@
1
1
  Post Status Notifier Liteを使えば、とりあえず好きなように設定できると思います。
2
2
 
3
3
  Post Status Notifier Lite
4
- [https://wordpress.org/plugins/post-status-notifier-lite](https://wordpress.org/plugins/post-status-notifier-lite)/
4
+ [https://wordpress.org/plugins/post-status-notifier-lite/](https://wordpress.org/plugins/post-status-notifier-lite/)