http://wpcj.net/1190
こちらのコードを投稿者に送信するように変更するコードをご教示いただきましたが、
2種類のフォームがあり、どちらもレビュー待ちで投稿されます。
管理者にくるメールは同じでもいいのですが、投稿者にメールを送信する内容は、それぞれのフォームに合った内容にしたいです。
教えて頂いたコード
function mail_for_pending( $new_status, $old_status, $post ) {
$user_id = $post ->post_author;
$user_info = get_userdata( $user_id );
$user_email = $user_info->user_email;
// 投稿がレビュー待ち以外からレビュー待ちに変わった(新規の場合は$old_statusが'new'、$new_statusが'pending'になります) if ( $old_status != 'pending' && $new_status == 'pending' ) { // ブログ名(サイト名) $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // 投稿名 $post_title = wp_specialchars_decode($post->post_title, ENT_QUOTES); // 送信先(管理者) ※ここを投稿者に変更 //$to = get_option('admin_email'); $to = $user_email; // 件名 $subject = "[{$blogname}] 承認待ちの投稿が投稿されました({$post_title})"; // 本文 $message = "承認待ちの投稿「{$post_title}」が投稿されました。確認をお願いします。\r\n"; $message .= "\r\n"; $message .= "編集および公開: \r\n"; $message .= wp_specialchars_decode(get_edit_post_link( $post->ID ), ENT_QUOTES) . "\r\n"; // メールを送信 $r = wp_mail( $to, $subject, $message ); }
}
add_action( 'transition_post_status', 'mail_for_pending', 10, 3 );
変更したコード
//投稿者にメール送信
function mail_for_pending( $new_status, $old_status, $post ) {
$user_id = $post ->post_author;
$user_info = get_userdata( $user_id );
$user_email = $user_info->user_email;
// 投稿がレビュー待ち以外からレビュー待ちに変わった(新規の場合は$old_statusが'new'、$new_statusが'pending'になります) if ( $old_status != 'pending' && $new_status == 'pending' ) { // ブログ名(サイト名) $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // 投稿名 $post_title = wp_specialchars_decode($post->post_title, ENT_QUOTES); // 送信先(管理者) ※ここを投稿者に変更 //$to = get_option('admin_email'); $to = $user_email; // 件名 $subject = "[{$blogname}] 求人情報が登録されました({$post_title})"; // 本文 $message = "「{$post_title}」の求人情報が登録されました。\r\n"; $message = " ご入金の確認が取れましたら、公開いたします。\r\n"; $message .= "\r\n"; $message .= "[{$blogname}] \r\n"; $message .= "http://*********.com/ \r\n"; // メールを送信 $r = wp_mail( $to, $subject, $message ); }
}
add_action( 'transition_post_status', 'mail_for_pending', 10, 3 );
投稿者に編集・公開をしてもらわないので、変更しました。
この求人情報の登録とは別にもう一つレビュー待ちになるフォームがあります。
どちらもカスタム投稿タイプです。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー