Support

Account

Home Forums Front-end Issues the_field and get_field is not working in get_users loop Reply To: the_field and get_field is not working in get_users loop

  • Hey, @vverner, thanks for the reply! I added your code (not sure if it’s in the right place though ) but nothing happened. The code below still just outputs the display_name but not the org_name field.

    Is it in the wrong place? What else am I doing wrong?

    
    <?php
    
        $args = array(
            'role'         => 'organization',
            'orderby'      => 'login',
            'order'        => 'ASC',
        );
        $org_users = get_users( $args );          
        foreach ($org_users as $user) {
            $user_id = get_current_user_id();
            get_field("org_name","user_".$user_id); 
    
            echo '<div class="resource-item">';
            echo '<p>';
            echo esc_html( $user->display_name );
            echo the_field("org_name","user_".$user_id); 
            echo '<br>';
            echo '</p>';
            echo '</div>';
        }
    
    ?>