Home Forums ACF PRO user relationship field query – how to?


user relationship field query – how to?

  • i have a page with a “user relationship” field. i want the selected users to show on the frontend of that page with their name, custom field entrys (phone nuber …) etc.:
    ACF field on page

    i get the data of the “normal” fields like display name etc. but how to get the data of my custom fields of the users (like “telephone”, “birthdate” etc.) :

    	$values = get_field('personen_intern');
    	echo '<ul>';
    	foreach($values as $value)
    		echo '<li>' . $value['display_name'] . '</li>';
    	echo '</ul>';
  • I think i have to do a user query like this:

    – getting all users
    – check if the user IDs are equal to an ID in the custom field entrys added to the page
    – than drop the ones whos ID is not in

    EDIT: this is the solution. So simple that I could not get it 😀

        //get the users
        $ids = get_field('personen_intern', false, false);
        //include them in the query
        $args = array(          
            'include' => $ids,
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘user relationship field query – how to?’ is closed to new replies.