Skip to content

Instantly share code, notes, and snippets.

@hypeJunction
Last active December 18, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hypeJunction/5724079 to your computer and use it in GitHub Desktop.
Save hypeJunction/5724079 to your computer and use it in GitHub Desktop.
Elgg/Elgg #5598
$user = elgg_get_logged_in_user_entity();
// Create test blog entry with some metadata
$location = 'New York City, USA';
$tags = array('photography', 'web design', 'art');
$blog = new ElggObject();
$blog->subtype = 'blog';
$blog->title = 'Some title';
$blog->description = 'Some content';
$blog->owner_guid = $user->guid;
$blog->container_guid = $user->guid;
$blog->access_id = ACCESS_PUBLIC;
$blog->location = $location;
$blog->tags = $tags;
$blog->save();
exit;
// Try assinging some new metadata using create_metadata()
$location = 'Berlin, Germany';
$tags = array('fashion', 'design clothing', 'sprint collection');
$blogs = elgg_get_entities(array(
'types' => 'object',
'subtypes' => 'blog',
'limit' => 1
));
$blog = $blogs[0];
$user = elgg_get_logged_in_user_entity();
print_r($blog->location);
print_r($blog->tags);
create_metadata($blog->guid, 'location', $location, '', $blog->owner_guid, ACCESS_FRIENDS);
foreach ($tags as $tag) {
create_metadata($blog->guid, 'tags', $tag, '', $blog->owner_guid, ACCESS_FRIENDS, true);
}
print_r($blog->location);
print_r($blog->tags);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment