Support

Account

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