Support

Account

Home Forums General Issues How to auto-populate WPForms 'Dynamic Post Type Source' dropdown with a list of Reply To: How to auto-populate WPForms 'Dynamic Post Type Source' dropdown with a list of

  • It has been a very long time since I’ve done this and a better source of information would be to contact support over at WPForms, they are generally very helpful.

    But, I did once upon a time create do dynamic generation of field choices for a WPForms field. It involved using this hook

    
    $filtered_field = apply_filters( "wpforms_{$field['type']}_field_display", $field, $attributes, $form_data );
    

    You can supply a filter for each field type. Here is a list of all the filters available for WPForms.

    I can tell you that you need to check the form ID $form_data['id'] and the field ID $field['id'] to make sure that you are altering the correct field.

    Just like acf there is $field['choices'] and each choice is an array

    
    array(
      'label' => 'XXXXX',
      'value' => 'YYYYY'
    )
    

    and that there may be other indexes depending on the field type.

    That is a about the extent of what I can offer.

    I did use a lot of this when I was building the filter and just like ACF it gave me information about the field I was working on at the time.

    
    echo '<pre>'; print_r($field); echo '</pre>';