Skip to content

Commit f6eb744

Browse files
committed
gpeb-gfapc-update-post.php: Added a new snippet to update post with using GFAPC addon.
1 parent bfa5e5c commit f6eb744

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Entry Blocks // Update Post on Entry Edit
4+
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5+
*
6+
* Use this snippet to update the original post created by an entry when that entry is edited. By default, Gravity Forms
7+
* would create a new post.
8+
*
9+
* This only works with the GF Advanced Post Creation add-on.
10+
*/
11+
12+
add_filter( 'gform_gravityformsadvancedpostcreation_pre_process_feeds', function( $feeds, $entry, $form ) {
13+
$feeds = GFAPI::get_feeds( null, null, 'gravityformsadvancedpostcreation' );
14+
foreach ( $feeds as $feed ) {
15+
$entry_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' );
16+
$post_feed = array_filter( $entry_posts, function( $post ) use ( $feed ) {
17+
return $post['feed_id'] == $feed['id'];
18+
} );
19+
20+
if ( ! empty( $post_feed ) && gf_advancedpostcreation()->is_feed_condition_met( $feed, $form, $entry ) ) {
21+
gf_advancedpostcreation()->update_post( $post_feed[0]['post_id'], $feed, $entry, $form );
22+
}
23+
}
24+
}, 10, 3 );

0 commit comments

Comments
 (0)