Summary
Allows for entity reference fields that reference user profiles to be used as the source for a Workbench Email template recipient.

Use Case
A common use case that I've run into on a few projects involves assigning content to an individual and emailing that user to notify them that their review has been requested.

I've accomplished this in the past by adding two fields to nodes where I'd like this functionality:

  • an entity reference field that references user profiles
  • an email address field

Then, using hook_ENTITY_TYPE_presave() I would look up the email address for that particular user and copy over the user's email address to the email field. This would allow me to use the built in functionality in Workbench Email that references a value from an email address field. Rather than continuing with this approach, I added functionality to Workbench Email to allow for entity reference fields to be used.

Approach
The attached patch augments Workbench Email by using the same techniques for discovering entity reference fields as Workbench Email currently uses for email address fields.

How to Use

  1. Add in the following patch to your codebase (preferably through composer)
  2. Add an entity reference field that targets user entities to a node
  3. You may now use this field when setting up your email templates

Comments

patrickfweston created an issue. See original summary.

patrickfweston’s picture

StatusFileSize
new6.29 KB
larowlan’s picture

I would prefer to focus on #2897697: Refactor recipient types into plugins which would allow this to be done in a decoupled fashion

patrickfweston’s picture

I'll look into that and will try to contribute if possible.

larowlan’s picture

Status: Active » Postponed
Issue tags: +Release blocker, +Recipient plugins
larowlan’s picture

Assigned: Unassigned » larowlan
Status: Postponed » Active
larowlan’s picture

Status: Active » Needs review
StatusFileSize
new16.21 KB
new183.97 KB

patch against plugins refactor (do not test file) and full patch including that for testing

Status: Needs review » Needs work

The last submitted patch, 7: 2923232-user-reference.patch, failed testing. View results

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new16.63 KB
new424 bytes
new81.04 KB

Missed a spot

Status: Needs review » Needs work

The last submitted patch, 9: 2923232-user-reference.8.patch, failed testing. View results

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new184.01 KB

forgot --binary

larowlan’s picture

StatusFileSize
new11.72 KB

reroll

Status: Needs review » Needs work

The last submitted patch, 12: 2923232-user-reference-12.patch, failed testing. View results

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new11.46 KB

merge cruft

Status: Needs review » Needs work

The last submitted patch, 14: 2923232-user-reference-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new12.12 KB

more merge cruft

Status: Needs review » Needs work

The last submitted patch, 16: 2923232-user-reference-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new15.99 KB

Status: Needs review » Needs work

The last submitted patch, 18: 2923232-user-reference-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new16.76 KB

Status: Needs review » Needs work

The last submitted patch, 20: 2923232-user-reference-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new18.66 KB

Sorting looks to be different on bot to local, test passes there

Status: Needs review » Needs work

The last submitted patch, 22: 2923232-user-reference-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Status: Needs work » Needs review
StatusFileSize
new18.66 KB

  • larowlan committed 78678d0 on 8.x-1.x
    Issue #2923232 by larowlan, patrickfweston: Allow values from entity...
larowlan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.