Home Forums ACF PRO Getting data from User relationship field


Getting data from User relationship field

  • I’m trying to get various pieces of data from an array of users added through the User Field, which is also assigned to all user profiles.

    Below is the code I’m using to get the array and then to try and get the IDs.

    $user = get_field('worked_with', $user_id_prefixed); // this gives us an array of all user data..
    $userID = $user["ID"];   // grabs the user ID
    echo $userID;

    The array is returned successfully. I just appear to be trying to get the ID incorrectly.

  • This was resolved by including a foreach:
    foreach ($users as $user) {}

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.