elgg_get_annotations doesn't return user's comments exactly

Suppose that user with GUID 35 has a blog post (GUID=100), and he post a comment on it. So in annotations table, this comment has owner_guid = 35, and entity_guid=100.

Then another user with GUID 45 post a comment on blog post above (GUID=100), in the annotations table this comment has owner_guid=45, and entity_guid=100.

And now, I want to get the comment of user with GUID=45. I use this code but it doesn't work, it returns nothing.

$options = array(
                'annotation_name' => 'generic_comment',
                'owner_guid' => array(45),
                'reverse_order_by' => true,
                'limit' => $num,
                'type' => 'object',
                'subtypes' => 'blog',
            );

$comments = elgg_get_annotations($options);

But when I change the owner_guid in options array to 35, it returns both comment of user 35 and user 45 (althought comment of user 45 has owner_guid=45).

Anyone can explain for me how does it work and how to solve my problem?

Sorry for my bad English. Thanks for reading.

  • annotation_owner_guid instead of owner_guid might be what you want.

    You might also take care if using singular annotation_owner_guid or plural annotation_owner_guids. It's either

    'annotation_owner_guid' => 45,

    or

    'annotation_owner_guids' => array(45),

    When using owner_guid the singular / plural difference is the same. For all possible options of elgg_get_annotations or any other Elgg function you can check out http://reference.elgg.org.

  • Thanks iionly, I have missed the annotation_owner_guid parameter on the elgg reference website. I solved my problem.