Hello, I have a problem displaying user data. I have a Group field with a company_name subfield and I want to display the content on the post loop.
My Code:
$user_ID = get_current_user_id();
if( have_rows('adress_group') ):
while( have_rows('adress_group') ): the_row();
// variablen
$company_name = get_sub_field('company_name', 'user_'.$user_ID);
endwhile;
endif;
echo $company_name;
Unfortunately the code doesn’t work. What is wrong?
Thank you for your help Best regards Peter
If the field is on a user then you need to supply the correct post ID for ACF
if( have_rows('adress_group', 'user_'.$user_ID) ):
while( have_rows('adress_group', 'user_'.$user_ID) ): the_row();
https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/
Hello and thanks for the quick reply. Your code works. My day is saved.
Thank you for your help Best regards Peter