Home Forums General Issues Multiple Select User Field and update_field() Reply To: Multiple Select User Field and update_field()

  • My apologies, I knew in my wall of text I would omit things. That code in its entirety is actually –

      $value = '21';
      // format value
      if( !$value || $value == 'null' )
        return false;
      // temp convert to array
      $is_array = true;
      if( !is_array($value) )
        $is_array = false;
        $value = array( $value );
      foreach( $value as $k => $v )
        $user_data = get_userdata( $v );
        //cope with deleted users by @adampope
        if( !is_object($user_data) )
          unset( $value[$k] );
        $value[ $k ] = array();
        $value[ $k ]['ID'] = $v;
        $value[ $k ]['user_firstname'] = $user_data->user_firstname;
        $value[ $k ]['user_lastname'] = $user_data->user_lastname;
        $value[ $k ]['nickname'] = $user_data->nickname;
        $value[ $k ]['user_nicename'] = $user_data->user_nicename;
        $value[ $k ]['display_name'] = $user_data->display_name;
        $value[ $k ]['user_email'] = $user_data->user_email;
        $value[ $k ]['user_url'] = $user_data->user_url;
        $value[ $k ]['user_registered'] = $user_data->user_registered;
        $value[ $k ]['user_description'] = $user_data->user_description;
        $value[ $k ]['user_avatar'] = get_avatar( $v );
      // de-convert from array
      if( !$is_array && isset($value[0]) )
        $value = $value[0];

    Sorry about that.

    So this was my code, but my issue from before still stands. I wouldn’t be able to output the array of $value and check the types using gettype as I previously mentioned if this was not the case.

    I updated my original post to reflect this, so it’s not confusing to someone reading it for the first time. Thanks!