How to search user specific content in Elgg

For example, how can I find a keyword "abcd" in User "Xyz"'s blogs, if possible in a specified time, eg, March 2010 or April 2010 to May 2011, for example? The point is to whether a certain user (say a poet) has used a certain word (say, romantic ponds) in any of his posts/blogs/content etc.

More specifically, can this be done in Elgg 3x ?  Many thanks.

  • elgg_get_entities([
      'type' => 'object',
      'subtype' => 'blog',
      'owner_guid' => $user_guid, // User xyz's guid 
      'metadata_name_value_pairs' => [
          ['name' => 'description', 'value' => '%abcd%', 'operand' => 'LIKE'],
          ['name' => 'time_created', 'value' => strtotime('01 March 2010'), 'operand' => '>='],
          ['name' => 'time_created', 'value' => strtotime('31 March 2010'), 'operand' => '<='],
      ],
    ]);

    I have not tested the code but this should do the trick. And the code is for Elgg 3.x.

  • @Rohit Gupta It's not a valid code.
    @kanha :
    $dbprefix = elgg_get_config('dbprefix');
    $start = strtotime('01 March 2010');
    $end = strtotime('31 March 2010');
    $content = elgg_list_entities([
      'type' => 'object',
      'subtype' => 'blog',
      'owner_guid' => $user_guid,
      'joins' => ["JOIN {$dbprefix}objects_entity oe on e.guid = oe.guid"],
      'wheres' => ["oe.description LIKE '%abcd%' AND e.time_created BETWEEN {$start} AND {$end}"],
    ]);
  • Hi RvR, I just tested my code and its 100% working. I created a blog having the string abcd in description. I executed my code and it gave me the exact blog guid and other relevant details.

    Here's a screenshot for you.

    May I know what made you think that the code is wrong.

  • Many thanks from the core of my heart. Can it be released (by any of you) as an Elgg 3 plugin ? Thanks again.