Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressで投稿記事を公開した際に投稿者にメールを送る方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressで投稿者の記事が公開されたときに、投稿者にメールを送りたいですか?

複数著者のブログを運営している場合、ブログ投稿が公開されたときに著者に通知することで、著者は常に情報を得ることができます。さらに、投稿者はすぐにコンテンツを共有し、ディスカッションに参加することができるため、サイトのエンゲージメントを高めることができます。

この投稿では、WordPressで投稿者の記事が公開されたときにメールを送る方法を紹介します。

Email authors when their articles are published in WordPress

WordPressで投稿者が記事を公開したときになぜメールを送るのか?

WordPressブログに投稿が公開されたら投稿者に通知することで、投稿者はすぐにソーシャルメディアプラットフォームで作品を宣伝したり、コメント欄で読者とコミュニケーションを取ったりすることができます。

さらに、投稿者に投稿ステータスの更新を通知します。これは、複数著者のブログへの投稿者の貢献を評価していることを示すことで、チーム間の信頼構築に役立ちます。

投稿後すぐに投稿者にアラートを出すことで、投稿者が自分のコンテンツを表示し、訪問者が読む前に誤字やエラーを修正する機会を与えることもできます。

それでは、WordPressで投稿者が記事を公開した際に、簡単にメールを送る方法を見ていきましょう。以下のリンクからお好きな方法にジャンプできます:

方法1:プラグインを使ってWordPressで投稿者の記事が公開されたら投稿者にメールを送る

WordPressの投稿が公開されたときに投稿者に通知するプラグインを使用したい場合は、この方法が適しています。

まず、PublishPress Plannerプラグインをインストールし、有効化する必要があります。詳しい手順については、WordPressプラグインのインストール方法についての初心者ガイドをご覧ください。

注: PublishPress Proプランをご利用いただくことで、Slackとの連携、リマインダー通知の送信、メタ情報の投稿など、より多くの機能をアンロックすることも可能です。これは、あなたの複数著者ブログの全体的な編集ワークフローを改善するのに役立ちます。

有効化した後、WordPress管理サイドバーからプランナー ” 設定ページにアクセスし、「通知」タブに切り替えてください。

投稿者にメールを送信する際に使用する管理者メールアドレスを、「Eメール送信元」設定の横に入力してください。

その後、’Always notify the author of the content’オプションにチェックを入れると、投稿者が投稿日: に公開するたびに投稿者にメールが送信されます。

Check the always notify author option

投稿を編集したWordPressユーザーにも通知したい場合は、「コンテンツを編集したユーザーに常に通知する」設定にチェックを入れてください。

完了したら、「変更を保存」ボタンをクリックして変更を保存します。

これで、投稿者の記事を公開すると、その投稿者のメールに次のような投稿通知が届きます:

Preview of author email notification upon post publication

方法2:WordPressで投稿者の記事が公開されたときにコードを使用して投稿者にメールを送る

プラグインを使いたくない場合は、テーマのfunctions.phpファイルにコードを追加することで、投稿者に自動的にメールを送信することもできる。

しかし、コードを追加する際のわずかなエラーで、サイトが壊れてアクセスできなくなることがある。

そのため、WPCodeを常に使用することをお勧めします。それはあなたのサイトにカスタムコードを追加するために、超安全かつ簡単に市場で最高のWordPressコードスニペットプラグインです。

まず、WPCodeプラグインをインストールし、有効化する必要があります。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

注:このチュートリアルにはWPCodeの無料プランも使えます。しかし、プロバージョンにアップグレードすると、コードスニペットライブラリ、条件ロジックなど、より多くの機能を利用できるようになります。

有効化したら、WordPressダッシュボードからCode Snippets ” + Add Snippetページにアクセスします。

次に、「カスタムコードを追加(新規スニペット)」設定の下にある「スニペットを使用」ボタンをクリックします。

Add new snippet

カスタムスニペットの作成」ページが表示されますので、まずはコードスニペットのタイトルを追加してください。

その後、右側のコードタイプのドロップダウンメニューから「PHP Snippet」オプションを選択します。

Choose the PHP Snippet option for emailing authors upon post publication

次のカスタムコードをコピー&ペーストして「コードプレビュー」ボックスに入れてください:

function notifyauthor($post_id) {
 
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "Post Published: ".$post->post_title."";
 
$message = "
      Hi ".$author->display_name.",
       
      Your post, \"".$post->post_title."\" has just been published.
       
      View post: ".get_permalink( $post_id )."
       
      Thanks"
      ;
       
   wp_mail($author->user_email, $subject, $message);
}
add_action('publish_post', 'notifyauthor');

このコードはWordPressで新しい投稿が公開されたときに実行されます。コードで定義された件名とメッセージを使って投稿者にメール通知を送信します。件名とメッセージのフィールドは自由に変更してください。

挿入」セクションまでスクロールダウンし、「自動挿入」モードを選択します。有効化したコードは、あなたのサイトで自動的に実行されます。

Choose an insertion method

最後に、一番上までスクロールして戻り、「Inactive」スイッチを「Active」に切り替える。

その後、「Save Snippet」ボタンをクリックして設定を保存します。

Save the snippet for emailing authors upon post publication

これで、WordPressサイトで投稿を公開すると、投稿者に自動的にメール通知が届くようになります。

このようになる:

Preview for sending email notification to authors upon post publication

ボーナス: WP Mail SMTPを使用してメールを送信します。

公開した投稿について投稿者にメールを送信する際、WordPressの初期設定を使用していますが、これは必ずしも信頼できるものではありません。

つまり、投稿者にメールが届かなかったり、スパムフォルダーに入ってしまったりする可能性があるのです。

この問題を解決するには、市場で最高のWordPress SMTPプラグインであるWP Mail SMTPを使用することができます。

WP Mail SMTP website

メール送信にはSMTP(Simple Mail Transfer Protocol)方式を採用し、メール配信の問題を解消します。

本当に〜してもよいですか?あなたは簡単にWP Mail SMTPと一般的なメールマーケティングサービスを接続し、あなたのメールがすぐにユーザーの受信トレイに到達することを確認することができます。

また、スパムフォルダーを避けたり、メールログを追跡したり、バックアップ接続や障害アラートを使用したり、ユーザーへのメール送信にあらかじめ用意されたテンプレートを使用したりすることもできます。

詳しい手順については、WordPressのメール設定を正しく行うための初心者向けガイドをご覧ください。

WordPressで投稿者の記事が公開されたときにメールを送る方法について、この投稿がお役に立てれば幸いです。WordPressで投稿者のコメントをハイライトする方法についてのチュートリアルや、WordPressサイトに最適な無料の投稿者プロフィールボックスプラグインのエキスパートピックもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

11件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Mrteesurez says

    Yes, I run a multi-author blog and I need this. I used to manually notify them through calls or chat to inform them of their post status but this article will be useful to solve this issue and this will even increase authors value. thanks.

  3. Jiří Vaněk says

    Engaging the author immediately after their post is published is a great way to non-violently get them to interact much faster and better with the readers of their post. Thanks to this, he can practically immediately monitor, for example, the comments under the article, and he can also, from the position of the author, immediately specify questions that may be of interest to his readers. At the same time, it keeps the article writers in better touch with the audience, so it’s a win-win.

  4. Konrad says

    Notifying authors about published articles is a win-win. Enhances engagement, promotes immediate sharing, and fosters a sense of trust within the blogging team.

  5. Moinuddin Waheed says

    Notifying authors of their content getting published will act like giving a feedback loop and a motivation to engage with the content and share to reach more audience.
    I used to use the same way to notify my news blog authors of their content getting published and it helped reach more engagement with the content.

  6. Efma says

    Any help as to how will I go about notifying the author of a post when a post status has been changed back to draft?

  7. Yoav says

    hey
    i’m using Method 3 (adding code to function.php) and it worked fine for some time . but now it’s sends 4 email to the author instead of 1. do you have any idea what went wrong?
    Thanks a lot

  8. Augusto says

    Hi, first of all thank you for your great article and sorry for my bad english… I am italian.

    Well, I need a suggest…. but my scenario is different, anyway this is the situation:

    1) I manage a multi authors site.
    2) They can publish without any control (they are all journalists, so the authors can publish in “real time”)
    3) My authors ask me to add a little form under their post (like the classic mailing list form)
    4) The purpose of this form is to send and email to the subscribers only when the author of the post publish a new post.

    In a few words. The author John write a post. The visitor Adam fill in the form (under the post) with his name and email, and from this moment, every time John will write a new post wp will notify the event to Adam and to all the others John’s subscribers.

    The question: there is on the market a plugin like this?
    A big thanks!!

    Augusto

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。