Support

Account

Home Forums General Issues User Field, How to retrieve author name from array

Solved

User Field, How to retrieve author name from array

  • Hello,

    I am using the ‘User’ relationship field to define the author of text box. It works, but all the information is stored in an array.

    var_dump:

    array(11) { [“ID”]=> int(1) [“user_firstname”]=> string(4) “BONE” [“user_lastname”]=> string(8) “Creative” [“nickname”]=> string(9) “boneadmin” [“user_nicename”]=> string(9) “boneadmin” [“display_name”]=> string(9) “boneadmin” [“user_email”]=> string(23) “[email protected]” [“user_url”]=> string(0) “” [“user_registered”]=> string(19) “2014-08-15 03:41:30” [“user_description”]=> string(0) “” [“user_avatar”]=> string(236) ”

    How do I retrieve the user id from this:

    array(11) { [“ID”]=> int(1)

    I know this is basic PHP … I am stumped!

    Any assistance you can provide would be much appreciated!

    Thanks!

  • This works!

    <?php
    $author = get_field('acf_author'); 
    echo $author = $author['ID'];
    ?>
  • Thanks this solved my problem.

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

The topic ‘User Field, How to retrieve author name from array’ is closed to new replies.