How to search entity by its owner name

I have been trying to create customized search for my plugin. I want it to search either by title, description, or username. 

For example:

//inside my search function 

function customized_search($search_query) {

   $options = [

      'type' => 'object',

      'subtype' => 'my_subtype',

   ];

   $options['joins'] = ["JOIN metadata met ON met.entity_guid = e.guid"];

   $options['wheres'] = ["met.value LIKE '%$search_query%'"];

   return elgg_list_entities($options);

}

This function works when searching by 'title' or 'description' but not by username. How can I make 'searching by username' to work?

Thanks!

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking