Content Moderation Notifications

Sends email notifications to users when content transitions between moderation states via Drupal's Content Moderation module.

content_moderation_notifications
9,488 sites
63
drupal.org

インストール

Drupal 11, 10, 9 v8.x-3.8
composer require 'drupal/content_moderation_notifications:8.x-3.8'
Drupal 8 v8.x-3.4
composer require 'drupal/content_moderation_notifications:8.x-3.4'

概要

Content Moderation Notificationsモジュールは、コンテンツがワークフロー状態遷移を経る際に自動メール通知を可能にすることで、DrupalコアのContent Moderation機能を拡張します。これは、チームメンバーがコンテンツのステータス変更について通知を受ける必要がある編集ワークフローにおいて不可欠です。

このモジュールにより、サイト管理者は特定のワークフロー遷移をターゲットとする複数の通知ルールを作成できます。通知は、特定のロールを持つユーザー(アクセス検証付き)、コンテンツ作成者、カスタムメールアドレス、またはエンティティ参照フィールドで参照されているユーザーに送信できます。このモジュールは、メールの件名、本文、アドホックメールフィールドでTwigテンプレートをサポートしており、条件ロジックやエンティティフィールドへのアクセスを含む強力なカスタマイズオプションを提供します。

アドホックメール以外のすべての受信者は、送信前にアクセス権限がチェックされ、ユーザーが閲覧可能なコンテンツの通知のみを受信することが保証されます。メールは受信者のプライバシーを保護するためにBCCヘッダーを使用して送信され、サイトのメールアドレスをオプションでプライマリ受信者として含めることができます。

Features

  • 異なるワークフロー遷移に対して複数の通知ルールを作成
  • 指定されたロールを持つすべてのユーザーに通知を送信(エンティティ閲覧アクセス検証付き)
  • コンテンツ作成者に通知を送信
  • カスタム/アドホックメールアドレスに通知を送信
  • コンテンツのエンティティ参照フィールドで参照されているユーザーに通知を送信
  • メールの件名、本文、アドホックメールアドレスフィールドでTwigテンプレートをサポート
  • メールコンテンツでのTokenの置換をサポート(Tokenモジュールがインストールされている場合は強化)
  • 削除せずに個々の通知を有効化/無効化
  • Twigテンプレートでエンティティおよびユーザーコンテキスト変数にアクセス(エンティティのタイトル、バンドル、所有者情報、現在のユーザー情報)
  • メール本文コンテンツのテキストフォーマット選択
  • Drupalコアで定義されたすべてのContent Moderationワークフローをサポート
  • 受信者のプライバシーのためのBCCベースのメール配信
  • エンティティ同期中(例:マイグレーション)の通知スキップ
  • 送信前に通知データをカスタマイズするためのAlter hook

Use Cases

Editorial Review Workflow Notifications

Configure notifications to alert editors when content is submitted for review. Create a notification for the 'Submit for Review' transition, assign editor roles as recipients, and include entity details like title, author, and direct link to the content in the email body using Twig variables.

Author Notification on Publication

Notify content authors when their content has been published. Create a notification for the 'Publish' transition, enable the 'Email the author' option, and compose a congratulatory message that includes the published URL using Twig templating.

Department-Specific Notifications

Send notifications to department managers referenced in a content field. Add a user entity reference field (e.g., field_department_manager) to your content type, then select this field in the 'Entity Reference User Fields' section. Managers will automatically receive notifications for their department's content transitions.

Dynamic Recipient Lists via Twig

Use Twig templating in the Adhoc email addresses field to dynamically determine recipients based on content field values. For example, access a referenced entity's email field: {{ entity.field_department.entity.field_manager_email.0.value }}

Conditional Email Content

Use Twig conditionals in the email body to customize messages based on content properties. For example, add special instructions for urgent content or include different information based on the content type.

Multi-Step Approval Workflow

Create separate notifications for each step in a complex approval workflow. Configure distinct notifications for Draft to Review, Review to Legal, Legal to Final Approval, and Final Approval to Published transitions, each targeting the appropriate team members.

Tips

  • Use the Token module to easily browse and insert available tokens in your notification templates
  • When sending to roles, only users who can view the content will receive notifications - this prevents information leakage
  • The site email address is used as the primary recipient by default. Check 'Disable the site email address' if you want notifications sent only to BCC recipients
  • Twig variables available include: entity (the content), user (current user), plus shorthand properties like entity.title, entity.bundle, entity.owner.email
  • Combine Twig conditionals with entity fields to create dynamic, context-aware notification content
  • Test notifications in a development environment before deploying to production to ensure templates render correctly
  • Notifications are not sent during migrations or when entities are syncing - this is intentional to prevent notification floods

Technical Details

Admin Pages 6
Content Moderation Notifications /admin/config/workflow/notifications

Lists all configured content moderation notifications in a tabular format. Each row displays the notification label, associated workflow, status (enabled/disabled), transitions that trigger it, roles that receive it, whether the author is emailed, and any adhoc email addresses. Provides operations to edit, delete, enable, or disable each notification.

Add notification /admin/config/workflow/notifications/add

Form to create a new content moderation notification rule. Configure which workflow transitions trigger the notification, who should receive it, and compose the email content with optional Twig templating.

Edit notification /admin/config/workflow/notifications/manage/{content_moderation_notification}

Form to modify an existing content moderation notification rule. All fields from the add form are available for editing.

Delete notification /admin/config/workflow/notifications/manage/{content_moderation_notification}/delete

Confirmation form to permanently delete a content moderation notification rule.

Enable notification /admin/config/workflow/notifications/manage/{content_moderation_notification}/enable

Confirmation form to enable a disabled notification rule. Once enabled, emails will be sent when the configured transitions occur.

Disable notification /admin/config/workflow/notifications/manage/{content_moderation_notification}/disable

Confirmation form to disable an active notification rule. Disabled notifications will not send emails until re-enabled.

権限 1
Administer content moderation notifications

Create, edit, delete, enable, and disable content moderation notification rules. Users with this permission can access the notifications administration interface.

Hooks 1
hook_content_moderation_notification_mail_data_alter

Allows modules to alter the mail data before a notification is sent. This hook is invoked after all recipients have been gathered and before the email is dispatched.

Security Notes 4
  • Adhoc email addresses do not undergo access checking - use with caution and only include trusted addresses
  • Role-based recipients are verified for entity view access before receiving notifications
  • Emails are sent via BCC to protect recipient privacy and prevent reply-all issues
  • The module respects Drupal's text format security - choose appropriate formats for email body content