Get values from a user


All the template functions (get_field, the_field, etc) can be used to load values from a user, however, a second parameter is required to target the user. This is similar to passing through a $post_id parameter to target a specific post object.

The $post_id parameter needed is a string containing the word ‘user_’ and the user’s ID in the format; "user_{$user_id}".


Display a field

This example will display a field value from a user with an ID of 1.

<p><?php the_field('field_name', 'user_1'); ?></p>

Retrieving a field

This example will retrieve a field value from a user with an ID of 1.


$variable = get_field('field_name', 'user_1');

// do something with $variable


Working with the Repeater Field

Note that when inside of a have_rows loop, you do not need to use the $post_id parameter for any sub field functions (get_sub_field, the_sub_field)

<?php if( have_rows('repeater', 'user_1') ): ?>


    <?php while( have_rows('repeater', 'user_1') ): the_row(); ?>

        <li><?php the_sub_field('title'); ?></li>

    <?php endwhile; ?>


<?php endif; ?>


This example will find the author for the current post, and display custom field data from that user.


$author_id = get_the_author_meta('ID');
$author_badge = get_field('author_badge', 'user_'. $author_id );

<img src="<?php echo $author_badge['url']; ?>" alt="<?php echo $author_badge['alt']; ?>" />


We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.