I have a question. I have 2 types of custom field group: Group A and Group B. All I am using ACF. In Group A, I have field name course_trainer. This field type is a User type and can have multiple values.

In Group B, I have field name class_trainer.This field type is a Select type and cannot have multiple value. This field will display data from field course_trainer. Basically, I used dynamic select for data to display at class_trainer.

If course_trainer field type not using multiple values, I can manage to display the data but if field type can have multiple values, the data not display at all.

I create a function in function.php to display the dynamic select:

function acf_load_t_first_name2_field_choices($field) {
    global $post;
    //$post = $_GET['post'];
    // reset choices
    $field['choices'] = array();

    // get the textarea value from options page without any formatting
    $choices = get_field('t_first_name',$post->ID);

    // loop through array and add to field 'choices'
    if( is_array($choices) ) {

        foreach( $choices as $choice ) {

            $field['choices'][ $choice ] = $choice;



    // return the field
    return $field;


add_filter('acf/load_field/name=course_trainer', 'acf_load_t_first_name2_field_choices');

Can someone correct my codes? Please help me :(

1 Answer 1


Can you try this amendment and see if $field is returning as you expect?

$field['choices'][] = $choice;
  • I have tried this solution but the result still same. the select list not appear Mar 4, 2020 at 14:43
  • Thank you @KiwisTasteGood . the solution works for me. I am just change the $field['choices'][ $choice ] = $choice; to your solution $field['choices'][] = $choice; and change add_filter('acf/load_field/name=course_trainer', 'acf_load_t_first_name2_field_choices'); to add_filter('acf/load_field/key=field_5e4a373c551fe', 'acf_load_t_first_name2_field_choices');. the array and key is the problem. Thanks dude Mar 4, 2020 at 14:52
  • @user3239674 no problem glad to help! Mar 4, 2020 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.