I'll bet it's because repeaters are actually embedded forms and not really a component of the parent form. I wish I had the time to do some reverse engineering and figure out how to add repeaters to the parent form conditionals.
There may be a work around you can try with frm_after_create_entry hook. Repeater forms are processed by Formidable before the parent form. All the hooks that work for parent forms work for repeaters individually as well. You may be able to trigger an email manually when the repeater is processed if you can send it before the parent form is fully processed.
Hi Victor! This is really hard but I'm really stubborn! I can't use the frm_after_create_entry hook because I want this to happen on update. So I thought I should try the frm_pre_update_entry hook. I used that before to stop or allow an email to send successfully but not using a repeater. Below is the code I tested on an entry with just one repeater row. I updated a name field in the repeater which this code is set to check. It is basically the same as the first example here: https://formidableforms.com/knowledgebase/frm_pre_update_entry/
add_filter( 'frm_pre_update_entry', 'check_if_value_changed', 10, 2 ); function check_if_value_changed( $values, $entry_id ) { $display = "Entry ID " . $entry_id; console_log ($display); $field_id = 949; // name field in repeater $previous_value = FrmEntryMeta::get_entry_meta_by_field($entry_id, $field_id); $display = "Previous value " . $previous_value; console_log ($display); if ( isset( $values['item_meta'][ $field_id ] ) && $values['item_meta'][ $field_id ] == $previous_value ) { // Stop email action if the repeater name field value did not change add_action( 'frm_trigger_email_action', 'frm_stop_email', 1 ); $display = "No change in value, stop email from sending."; console_log ($display); } else { $display = "Updated value is " . $values['item_meta'][ $field_id ] . ", don't stop email from sending"; console_log ($display); } return $values; }
What I discovered is that this code runs twice - first for the parent entry, and then for the repeater entry. It does work, but I am testing a simple case first (only one repeater row). My goal is for it to work if there are multiple rows and send emails only for each row that gets updated. I'll try that next but I'm expecting it not to work that way because it appears that whatever the last result is on the comparison of previous and current values is the one that the action is set by. I attached a screenshot of what was written to the console when I updated the name in the repeater entry. Entry ID 363 is the parent entry (where the field values are empty because the field is not in that form), and Entry ID 362 is the repeater entry.
Ok, I tested this with two rows and as expected, it did not work the way I intended. I tested updating one of the repeater rows at a time and no emails were sent, but I did want an email for the one I updated to be sent. I had to update both rows to get emails to send, and one was sent for each row. That's normal behavior for a repeater email, but I want an email sent only to the email addresses in my repeater rows (entries) if a specific field value in each has been updated. Maybe this is just not possible?
Keep something in mind, each repeater row is an entry in its own right. if you have 10 repeaters rows, this will fire for every single entry and the parent. If you really want to limit the code, use the $_POST variable to get the repeater id and exit the function if it's not processing the repeater.
This sounds like the fix, but the function has entry_id as an argument so I don't need to use $_POST, do I? Then, wouldn't I need a way to identify the entry_id as a repeater entry and not the parent entry? How can I do that?
I would use $_POST to get the repeater form ID is use it if (form_id = 'repeater') { do this } else exit function.
Please login or Register to submit your answer