Title: Modify email message programatically
Last modified: January 7, 2021

---

# Modify email message programatically

 *  Resolved [yepecece](https://wordpress.org/support/users/yepecece/)
 * (@yepecece)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/modify-email-message-programatically/)
 * Hi,
 * I am trying to modify the email message for an email action via the ninja_forms_run_action_settings
   filter.
 * Here is my code:
 *     ```
       add_filter('ninja_forms_run_action_settings', 'sg_download_nf_success_message', 11, 4);
       function sg_download_nf_success_message($action_settings, $form_id, $action_id, $form_settings) {
       	if($form_id == 1 && $action_id = 2) {
       	$subject_message = get_field( 'subject_message', 'option' );
       	$form_message = get_field( 'form_message', 'option' );
       	$action_settings['email_subject'] = $subject_message;
       	$action_settings['email_message'] = $form_message;
       	}
       	return $action_settings;
       }
       ```
   
 * The problem is that this alters all messages and subjects for all my email action.
   
   How can I target the `['email_subject']` and `['email_message']` for a specific
   action.
 * Or is there a way to add acf fields (from an option page) via the merge tags 
   in the ninja forms interface?

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Justin McElhaney](https://wordpress.org/support/users/jmcelhaney/)
 * (@jmcelhaney)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/modify-email-message-programatically/#post-14085443)
 * adding ACF information to the fields, you would need to know the meta key for
   how the data is stored in the post meta or user meta database tables. You could
   then use the merge tags {user_meta:YOUR_META_KEY} and {post_meta:YOUR_META_KEY}
   to recall the data from ACF using the corresponding meta key.

Viewing 1 replies (of 1 total)

The topic ‘Modify email message programatically’ is closed to new replies.

 * ![](https://ps.w.org/ninja-forms/assets/icon-256x256.png?rev=1649747)
 * [Ninja Forms - The Contact Form Builder That Grows With You](https://wordpress.org/plugins/ninja-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ninja-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ninja-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/ninja-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ninja-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ninja-forms/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 1 reply
 * 2 participants
 * Last reply from: [Justin McElhaney](https://wordpress.org/support/users/jmcelhaney/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/modify-email-message-programatically/#post-14085443)
 * Status: resolved