Support » Themes and Templates » Array of user ids to display names

  • Resolved mantismamita

    (@mantismamita)


    I’m outputting an array of user ids from metadata like so:
    $awaygoalby = unserialize($post_meta_data['report_away-scorers'][0]); and I want to change each user id to the user name. So I was hoping to do something like this:

    foreach($awaygoalby as $string){
    $name = get_userdata( $string );
    echo $name;
    }

    Unfortunately I get an error saying that the “Object of class WP_User could not be converted to string.” What is the best way of doing this?

Viewing 1 replies (of 1 total)
  • I got the answer if anyone else is curious:

    foreach($awaygoalby as $string){
    $name = get_userdata( $string );
    echo $name-> display_name;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Array of user ids to display names’ is closed to new replies.