0

I am trying to get 1 item from an associative array that I am outputting form an ACF field.

I am doing the following:

print_r(get_field('consultant_name')); This is on the ACF field where I can select a specific user from a specific role.

The output of this is:

Array ( [ID] => 42 [user_firstname] => Sarah [user_lastname] => Piddington [nickname] => sarah_piddington [user_nicename] => sarah_piddington [display_name] => Sarah Piddington

The only part I need from this is the ID but im not sure how to access this on its own? Could somebody advise me if this even possible? I need it to use as a comparison.

1

You could just use:

echo get_field('consultant_name')['ID'];
  • np, could you mark as answered? – rudtek Jul 18 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.