Programmatically triggering specific email

Est. Reading: 1 minute
By: Rob LeVine
Created: 01/14/2023
Difficulty: Intermediate

Programmatically triggering specific email

So you want to programmatically fire off a form notification email?  Here's one way to do it.  Let's be clear that I have no idea if this is the "correct" way.  I just got sick of asking this question myself and seeing other people asking it, so I figured I'd try to solve it myself. Also, you'll need to figure out a way to populate the entry id (or entire entry) as well as the action_id.  See the comments in the code.

	$entry_id = 72; // somehow you have to set the entry id of the form entry you're dealing with
	$target_action_id = 177; // id of the action you want to fire off - you can get this from the database WP_POSTS with the post_type = 'frm_form_actions'
				 //  or get it from the FF UI by opening the action and scrolling all the way down to the bottom right where it says "Action ID:

	$entry = FrmEntry::getOne($entry_id, true);
	$form_id = $entry->form_id;
	$type = "email"; // whichever you want
       	$actionToDo = FrmFormAction::get_single_action_type( $target_action_id, $type );

	$form = FrmForm::getOne($form_id);

	FrmNotification::trigger_email( $actionToDo, $entry, $form );

2 comments on “Programmatically triggering specific email”

  1. This is a wonderful solution. Request for clarification and specificity for those of us with limited coding ability: Is this a single function? Any suggestions on how to get the entry id automatically? Thanks!

    1. It only took 7 months for me to find out that there was a question here...

      I'm not sure what you mean by "a single function". And I'm not sure what you mean by get the entry id automatically either. It all depends on the context in which you're implementing this concept.

Leave a Reply

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crosschevron-leftchevron-rightarrow-right