<?php
$involved_users = array();
//grab usernames from user reference field of a node
$project = entity_metadata_wrapper('node', $node);
// field_users is user reference field
foreach ($project->field_users as $acc) {
$involved_users[] = $acc->value()->name;
}
var_dump($involved_users);
?>
Hi Guys,
I got this bit of code from http://pixeljets.com/blog/writing-robust-code-uses-fields-drupal-7
I have been going through it but I can't seem to figure out how "$acc->value()->name;" work?
What is value()? Is it PHP method or a Drupal one. I can't find any documentation on this.
Thanks!
If you read the blog post you provided carefully, you'll see that the value()
method is provided by entity_metadata_wrapper()
from the Entity module.