WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Array of user ids to display names (2 posts)

  1. mantismamita
    Member
    Posted 1 year ago #

    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?

  2. mantismamita
    Member
    Posted 1 year ago #

    I got the answer if anyone else is curious:

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

Topic Closed

This topic has been closed to new replies.

About this Topic