Created
March 7, 2019 16:08
-
-
Save spivurno/2364580fe70f322c2c900740b85e832a to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Gravity Perks // Populate Anything // Populate Post Meta as Choices | |
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/ | |
*/ | |
// Update "123" with your form ID; Update "4" with your field ID. | |
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) { | |
$custom_field = str_replace( 'meta_', '', $field['gppa-choices-templates']['label'] ); | |
$meta = get_post_meta( $objects[0]->ID, $custom_field ); | |
$choices = array(); | |
foreach( $meta as $value ) { | |
$choices[] = array( | |
'text' => $value, | |
'value' => $value, | |
); | |
} | |
return $choices; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment