Home › Forums › General Issues › User field type › Reply To: User field type
Hi blueawesome
You need to query the database, this article helped me: http://www.advancedcustomfields.com/resources/querying-the-database-for-repeater-sub-field-values/
My code then had something like this:
<?php
$last = count($rows);
$i = 1;
foreach( $rows as $row ) {
preg_match('_([0-9]+)_', $row->meta_key, $matches);
$meta_key = 'team_' . $matches[0] . '_select_staff';
$user_id = get_post_meta( $row->post_id, $meta_key, true );
?>
Once I had the ID of the user, I could then do the following:
<h5><?php $user_info = get_userdata($user_id); $first_name = $user_info->first_name; $last_name = $user_info->last_name; echo "$first_name $last_name"; ?><?php #echo ' - '.$user_id; ?></h5>
I’ve no idea exactly what you’re trying to achieve but maybe the above will give you some pointers!
jeremey’s code is useful but if you’re using a repeater then you need to go the query route I believe
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.