WordCamp Europe 2023 Special Offer - Get 30% OFF any edition with coupon: WC30

My Account


Home Forums General Select Field: Change / Add own data sources Reply To: Select Field: Change / Add own data sources


You can do this via hook and erase the already existing contents and prefill it with our own.
Basically you can then prefill everything what you want 🙂


namespace ct_example;

class WsForm
    public static function Prefill($form)
        $fieldId = 123;
        $matchingField = &wsf_form_get_field($form, $fieldId);

        $prefillData = Helper::GetMyPrefillData(); // returns key/value pairs
        if ($prefillData) {
            foreach ($prefillData as $prefillEntryKey => $prefillEntryValue) {
                $row = (object)[
                    'default' => false, // you can create logic to preselect entries
                    'data' => [$prefillEntryValue, $prefillEntryKey] // you need to add the key/value fields to your dropdown!
                wsf_field_row_add($matchingField, $row);

        return $form;
add_filter('wsf_pre_render', ['\\' . __NAMESPACE__ . '\\WsForm', 'Prefill']);