function get_jet_meta_fields($field_name,$slug,$field_num){
add_filter('elementor_pro/forms/field_types', function ($types) use ($field_name) {
$types[$field_name] = ucfirst($field_name);
return $types;
});
add_filter('elementor_pro/forms/render/item/'.$field_name, function ($item, $item_index, $instance) use ($slug,$field_num) {
ob_start();
global $wpdb;
// this adds the prefix which is set by the user upon instillation of wordpress
$table_name = $wpdb->prefix . "jet_post_types";
// this will get the data from your table
// id,slug,status,labels,args,meta_fields
$retrieve_data = $wpdb->get_results( "SELECT slug,args,meta_fields FROM $table_name" );
$all_mata_fields = unserialize($retrieve_data[$slug]->meta_fields);
$select_options = $all_mata_fields[$field_num]["options"];
$field_options = [];
foreach ($select_options as $key => $val) {
$field_options[] = $select_options[$key]['value']. "|".$select_options[$key]['key'];
}
$item['field_options'] = implode("\n", $field_options);
$item['field_type'] = "select";
ob_get_clean();
return $item;
},99,3);
}
get_jet_meta_fields('locations',1,5);
get_jet_meta_fields('vacancy',1,6);