Thanks
That makes it much more clearer now. I didnt realise there was a difference between the array and post object setting.
I managed to get the correct wording to display in the drop down. Does this look like best practice for retrieving that info. But its now throwing errors in the wp-admin from this line = $studio_id = $GLOBALS[‘post’]->ID;
add_filter( 'gform_pre_render', 'freetrial_studios' );
add_filter( 'gform_pre_validation', 'freetrial_studios' );
add_filter( 'gform_pre_submission_filter', 'freetrial_studios' );
add_filter( 'gform_admin_pre_render', 'freetrial_studios' );
function freetrial_studios( $form ) {
foreach ( $form['fields'] as &$field ) {
if ( $field->type != 'select' || strpos( $field->cssClass, 'studio-list' ) === false ) {
continue;
}
$studio_id = $GLOBALS['post']->ID;
$studios = get_field('field_557a974776dd2', $studio_id);
if( $studios ) {
$choices = array();
foreach ( $studios as $studio ) {
// Populate the drop down field with values
$choices[] = array( 'text' => $studio->post_title, 'value' => $studio->post_title );
$field->choices = $choices;
}
$field->placeholder = 'Select a Studio';
$field->choices = $choices;
}
}
return $form;
}
Also Any idea on how i could get the value of that selected field, and retrieve a custom field that is related to that post ID eg. a custom email address field that i have set up for each studio.
Thanks