Get river of some users

Hello,

is there any method to fetch river only of users with a particular metadata value for a particular metadata field?

Thank you

  • What did you want to list from the users?

  • I want to filter the river only for users that have "New York" set as metadata "location" field, for example. Have I explained more clearly? 

  • Oh ok, you pretty much want to limit each user's river based on location. Something like a local feed right?

  • No I'm sorry, that was an example. I want to add a tab in activity page (one more than all, mine, following) in which I list only river activity of users with "Premium" value for "profile_type" field. I'm sorry if I didn't explain very well!

  • Ohhhhh, so a filter tab where only premium members can see other premium members' activities?

  • There's a good discussion here:

    https://elgg.org/discussion/view/2200450/how-to-combine-own-following-river-activity-tabs-into-one

    You need to custom code this function into your elgg network. I don't know if there's a plugin for that.

  • I was thinking about using joins and wheres options to get subject_guids only with correct metastrings associated. Do you think this is a good idea? Any tip on this argument?

  • Hello,

    I used this but it doesn't work. Any help? (If I remove joins and wheres it works)

    $db = elgg_get_config('dbprefix');
        $name_id = elgg_get_metastring_id('profilo_tipo');
        
        $value1 = elgg_get_metastring_id('Pro');
        $value2 = elgg_get_metastring_id('Business');
        
        $options = array(
            'offset'     => 0,
            'limit'      => 20,
            'type' => 'object',
            'subtypes' => array('hjwall', 'izap_videos', 'blog'),
             'no_results' => '',
        );
       
           $options['joins'][] = "JOIN {$db}metadata md1 ON (rv.subject_guid = md1.entity_guid)";
        $options['joins'][] = "JOIN {$db}metadata md2 ON (rv.subject_guid = md2.entity_guid)";
        
        $options['wheres'][] = "md1.name_id = {$name_id}";
        $options['wheres'][] = "md2.name_id = {$name_id}";
        $options['wheres'][] = "md1.value_id = {$value1}";
        $options['wheres'][] = "md2.value_id = {$value2}";

    $river = elgg_get_river($options);

  • I do not think you need two joins, one should be enough.

    How about

    $options['joins'] =array("JOIN {$db}metadata md ON rv.subject_guid = md.entity_guid");
    
    $options['wheres'] = array(("md.name_id = {$name_id}"),("md.value_id = {$value1} OR  md.value_id = {$value2}"));
    
    

    You can also search for the way this query is formulated in error_log and try it in phpMyAdmin to see what is wrong.