I’ve gotten GF to send partial entries to Active campaign. But I want to be able to send partial entries from different forms using the feed for the respective form.
This is what I setup but it only works for the 1st feed.
“Partial Entries - IC” feed works for the form it belongs to.
but “partial entries - custom” feed will not run for its respective form.
add_action( 'gform_partialentries_post_entry_saved', 'send_to_activecampaign_on_partial_entry_saved', 10, 2 );
function send_to_activecampaign_on_partial_entry_saved( $partial_entry, $form ) {
if ( class_exists( 'GFAPI' ) && function_exists( 'gf_activecampaign' ) ) {
$form_id = $form["id"];
$feeds = GFAPI::get_feeds( null, $form_id, 'gravityformsactivecampaign', false );
foreach ( $feeds as $feed ) {
if ( $feed["meta"]["feed_name"] == "Partial entries - IC tag" ) {
gf_activecampaign()->process_feed( $feed, $partial_entry, $form );
if ( $feed["meta"]["feed_name"] == "Partial entries - IC Custom" ) {
gf_activecampaign()->process_feed( $feed, $partial_entry, $form );
}
}
}
}
}
There appears to be an issue with the conditional statement in your code. Specifically, the second if statement that checks for the Partial entries - IC Custom feed is nested inside the first if statement that checks for the Partial entries - IC tag feed. As a result, the code for processing the Partial entries - IC Custom feed will only be executed if the first feed (Partial entries - IC tag) is found.
To rectify this, move the second if statement outside the first one and update the condition to check for the correct feed name. Here is the updated code:
add_action( 'gform_partialentries_post_entry_saved', 'send_to_activecampaign_on_partial_entry_saved', 10, 2 );
function send_to_activecampaign_on_partial_entry_saved( $partial_entry, $form ) {
if ( class_exists( 'GFAPI' ) && function_exists( 'gf_activecampaign' ) ) {
$form_id = $form['id'];
$feeds = GFAPI::get_feeds( null, $form_id, 'gravityformsactivecampaign', false );
foreach ( $feeds as $feed ) {
if ( $feed['meta']['feed_name'] == 'Partial entries - IC tag' ) {
gf_activecampaign()->process_feed( $feed, $partial_entry, $form );
}
if ( $feed['meta']['feed_name'] == 'Partial entries - IC Custom' ) {
gf_activecampaign()->process_feed( $feed, $partial_entry, $form );
}
}
}
}
This code will iterate over all the ActiveCampaign feeds for the current form and execute the gf_activecampaign()->process_feed() function for each feed that matches the respective feed name condition. This ensures that the Partial entries - IC Custom feed is processed correctly.
I cannot thank you enough Faisal. I owe you so much!