Drupal Entity_metadata_wrapper 各种数据类型

修改Profile2

$account = user_load(46); 
$profile = profile2_load_by_user($account, 'user_main');
$wrapper = entity_metadata_wrapper('profile2', $profile);
// 修改姓名字段
$wrapper->field_user_realname->set('周周秀坤');
$wrapper->save();

创建用户并绑定Profile2


$newuser = user_load(2);
$profile = profile2_create(array(
    'user' => $newuser,
    'type' => 'user_main'));

$wrapper = entity_metadata_wrapper('profile2', $profile);
$wrapper->field_user_realname->set('hello world');
$wrapper->save();

Poi Polygon

$polygon = 'POLYGON (1 2, 2 3,3 4)';
$geometry = geoPHP::load($polygon);
$wrapper->field_poi->set(geometry);