first_name
和last_name
不属于_users
表it是用户元数据。因此,用户对象没有它。所以当你访问该物业时first_name
用户对象有一个PHP魔术方法__get()
/**
* Magic method for accessing custom fields
*
* @since 3.3.0
* @param string $key
* @return mixed
*/
public function __get( $key ) {
if ( \'id\' == $key ) {
_deprecated_argument( \'WP_User->id\', \'2.1\', __( \'Use <code>WP_User->ID</code> instead.\' ) );
return $this->ID;
}
if ( isset( $this->data->$key ) ) {
$value = $this->data->$key;
} else {
if ( isset( self::$back_compat_keys[ $key ] ) )
$key = self::$back_compat_keys[ $key ];
$value = get_user_meta( $this->ID, $key, true );
}
if ( $this->filter ) {
$value = sanitize_user_field( $key, $value, $this->ID, $this->filter );
}
return $value;
}
查询元数据并从中返回值
_usermeta
桌子