Last active
August 3, 2020 11:50
-
-
Save kaskad88/132e9826515673c231d5452aebc43fb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'jet-engine/forms/booking/notification/insert_post', function( $notification, $manager ) { | |
$form_id = absint( $manager->form ); | |
if ( 1853 !== $form_id ) { // Need to change the Form ID | |
return; | |
} | |
$media_key = 'field_media2'; // Need to change the Media Field Name | |
if ( empty( $manager->data['inserted_post_id'] ) ) { | |
return; | |
} | |
if ( empty( $manager->data[ $media_key ] ) ) { | |
return; | |
} | |
$attachment_ids = explode( ',', $manager->data[ $media_key ] ); | |
foreach ( $attachment_ids as $attachment_id ) { | |
wp_update_post( array( | |
'ID' => $attachment_id, | |
'post_parent' => $manager->data['inserted_post_id'], | |
) ); | |
} | |
}, 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment