Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskinmedia/6f874a7b71df53bace240b5ac20a1960 to your computer and use it in GitHub Desktop.
Save maskinmedia/6f874a7b71df53bace240b5ac20a1960 to your computer and use it in GitHub Desktop.
Added target form to Gravity Wiz "Set Uploaded Image Data by Field Value" perk
add_filter( 'gpml_media_data', function( $media, $field, $entry ) {
// Replace 123 with the actual form ID
$target_form_id = 123;
// Check if the entry's form ID matches the target form ID
if ( $entry['form_id'] == $target_form_id ) {
// Replace "1", "2", "3" and "4" in each line below with the ID of the field that will contain the value that should be used for each image property.
$media['post_data']['post_title'] = rgpost( 'input_1' );
$media['post_data']['post_content'] = rgpost( 'input_2' );
$media['post_data']['post_excerpt'] = rgpost( 'input_3' );
$media['post_data']['post_meta']['_wp_attachment_image_alt'] = rgpost( 'input_4' );
}
return $media;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment