Hi John,
thanks for your fast answer, but I still have the same issue. My code looks now this way:
function numediaweb_custom_user_profile_fields($user) {
$objektsave = array();
$the_query = new WP_Query("post_type=immomakler_object&posts_per_page=-1&field=ids");
if ($the_query->have_posts()) {
global $post; // not sure if you need this or not, try it with and without
while ($the_query->have_posts()){
$the_query->the_post();
$save = get_the_ID();
$objektsave = get_post_meta($save,'objektnr_extern',true);
$objekt[] = $objektsave;
}
wp_reset_postdata();
}
return $objekt;
}
add_action('show_user_profile', 'numediaweb_custom_user_profile_fields');
add_action('edit_user_profile', 'numediaweb_custom_user_profile_fields');
/// DATA IN ACF
function acf_load_auswahlfeld_field_choices( $field ) {
$objekt = numediaweb_custom_user_profile_fields();
$field['choices'][] = $objekt;
return $field;
}
add_filter('acf/load_field/name=immoid', 'acf_load_auswahlfeld_field_choices');