Home Forums Front-end Issues Subfield User ID


Subfield User ID

  • 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);
    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();

  • Hello and thanks for the quick reply. Your code works. My day is saved.
    Thank you for your help Best regards Peter

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.