i need help with suppressing some river entries

hello everyone, i need help with  suppressing some river activity entries like "befriending", "profileupdateicon"....etc. i used the hide_river_entries plugin by

gfontaniere with the code in start.php below 

function suppress_river_entries($hook, $type, $value, $params) {
    $action_type = $value['action_type'];
    $view = $value['view'];
    // no river entries on avatar uploads
    if (($action_type == 'update') && ($view == 'river/user/default/profileiconupdate')) {
        return false;
    }
    // no river entries about friending
    if (($action_type == 'friend') && ($view == 'river/relationship/friend/create')) {
        return false;
    }
}

but it doesn't seem to be working....i am using elgg 2.x...thanks. 

  • You just need to override the views in the river folder in your plugin and leave the views blank. 

  • Or start.php

    <?php
    
    elgg_register_event_handler('init', 'system', 'hide_some_river_entries_init');
    
    /**
     * Initialize the plugin
     * @return void
     */
    function hide_some_river_entries_init() {
        elgg_register_event_handler('profileiconupdate', 'user', 'hide_profile_river_updates');
        
        elgg_unregister_action('friends/add');
        $action_path = __DIR__ . '/actions';
        elgg_register_action('friends/add', "$action_path/friends/add.php");
    }
    
    function hide_profile_river_updates($event, $type, $object) {
        return false;
    }

    and the action actions/friends/add.php (basically the core add.php with only the second parameter of addFriend() changed from true to false):

    <?php
    /**
     * Elgg add friend action
     *
     * @package Elgg.Core
     * @subpackage Friends.Management
     */
    
    // Get the GUID of the user to friend
    $friend_guid = get_input('friend');
    $friend = get_user($friend_guid);
    
    if (!$friend) {
        register_error(elgg_echo('error:missing_data'));
        forward(REFERER);
    }
    
    if (!elgg_get_logged_in_user_entity()->addFriend($friend->guid, false)) {
        register_error(elgg_echo("friends:add:failure", array($friend->name)));
        forward(REFERER);
    }
    
    system_message(elgg_echo("friends:add:successful", array($friend->name)));
    forward(REFERER);

    With these changes the river entries are not created in the first place. Meaning: if you later decide you want to show also such kind of entries from the past it won't work because the entries are not in the database. With @Cim's suggestion the entries are created in the database but supressed on the output due to the view being empty (but you will get less entries getting displayed on these pages in the river because the "empty" entries still count).

  • Thank You Cim and iionly for the support....you guys are smart and great developers..@iionly i think i will follow Cim's approach because i want the entries to be created in the database but suppressed on the output...once again, thanks for the support...best regards.

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