How to modify field values sent in notification emails

Created by Phil Kurth, Modified on Tue, 5 Jul, 2022 at 10:54 AM by Phil Kurth

Field value formatting is controlled by ACF and should reflect the Return Format setting on a field. If you need to display a field differently in an email notification, the best way is to create a custom merge tag and use that in the email notification content field.


Consider the following example. A radio button field type has been used and its Return Format is set to Both (Array). As a result, in the notification email, the submitted value appears in the format value, Label. If we want to return just the label, we can use a custom merge tag for that field as follows:

add_filter( 'af/merge_tags/resolve', function ( $output, $tag ) {
  if ( 'YOUR_CUSTOM_MERGE_TAG' != $tag ) {
    return $output;
  }

  // Assume this field has a `return_format` set to `array`.
  // This config results in both the value and label appearing in notification emails.
  $value = af_get_field( 'RADIO_FIELD_NAME' );

  // Return just the label.
  return $value['label'];
}, 10, 2 );


This merge tag can then be placed in the notification's Content field as so: {YOUR_CUSTOM_MERGE_TAG}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article