remove "commented on" river from activity Stream

Hi everyone,

When a user add a comment, we  have the following entry on the activity stream "**** commented on  ****** ",.

How can I remove such entry from activity stream ?

Regards,

 

  • Override this file.

    You should change $keys - look at this string.

    If you need to edit this string only not a view then use Translation editor plugin.

  • Thanks,

    May be I do not well explain my issue.

    Every time a user add a comment on and object , a new river is created on the activity stream. I do not what to display such river on the activity stream.

    How can I implement such behavior ?

    Regards,

     

  • Hi @RvR ,

    I still don't know how to do with my issue.

    Every time a user add post comment, a river is created on the activity stream. I do not want to display such river on the activity stream.

    I don't know how to do.

    Need Help.

    Regards, 

  • Untested code:

    function no_river_comment_entries_init() {
        elgg_register_plugin_hook_handler('creating', 'river', 'no_river_comment_entries');
    }
    
    
    function no_river_comment_entries(\Elgg\Hook $hook) {
        $returnvalue = $hook->getValue();
        
        $action_type = $returnvalue['action_type'];
        if ($action_type == 'comment') {
            return false;
        }
    
        return $returnvalue;
    }

    It might work with this code. I've not tested it but only taken some code from Tidypics I knew I used the 'creating', 'river' plugin hook and modified it a tiny bit to work on Elgg 3 (not sure if you use Elgg 2 or 3). On the latest Elgg 3 versions you probably can change it even further by not registering the plugin hook in start.php but in elgg-plugin.php. But I have to admit I haven't looked into Elgg 3.3 at all so I'm definitely not up to date with Elgg 3.3 (not much tried any Elgg 3 stuff in general yet...).

    The code above checks the value of action_type provided when using the elgg_create_river_item function. In case it's a comment it should prevent the creation of this river item by returning false. If the code does not work this way I hope I've given you at least a starting point to get it working on your own.

  • Thanks a lot. I am using elgg 3.3.1

    I did it that way. But $returnvalue['action_type'] always contains "create" so I cannot know if the action is a comment or not .

    Regards,

     

  • Ah, I'm definitely not yet into Elgg 3...

    Try

    function no_river_comment_entries(\Elgg\Hook $hook) {
        $action_type = $hook->getParam('action_type');
        
        if ($action_type == 'comment') {
            return false;
        }
    }
  • Thanks,

    But for almost all "rivers" tested,  the variable $action_type always contains "create" not "comment".

    Regards,

  • elgg_register_plugin_hook_handler('view', 'river/object/comment/create', function (\Elgg\Hook $hook) {
    
       return false;
    
    });
  • I've tested out the code myself now. And the first code I had posted works (actually the second of my suggestions is wrong). In most cases action_type is "create" of course (but these other types of river entries were not the ones you asked about...). But for the river entries added for comments it's "comment".

    I'm not sure what else to suggest. The idea of RvR in his last posting is actually quite interesting. Instead of preventing the creation it would just stop the entries from getting displayed, i.e. the change would be revertible.

    I've tested the follow code and it works for me. The code provides 3 modifications (1. not create the entries, 2. only hide the entries, 3. also hide the comment entries shown as "responses" below the entries the comments were added to). You would either use modification 1 OR 2 (I would recommend 2). Modifications 3 is independently usable with 1 and 2 or you could use only 3.

    The code (start.php):

    elgg_register_event_handler('init', 'system', 'river_no_comment_entries_init');
    
    function river_no_comment_entries_init() {
        // this plugin hook prevents new river entry from getting created when a comment is added
        // but still displays existing entries created on former comments made
        // keep in mind: with this hook in use river entries for comments are NOT CREATED ANYMORE and therefore won't show
        // even if you ever decide to no longer use this hook
        elgg_register_plugin_hook_handler('creating', 'river', 'river_no_comment_entries');
        
        // this plugin hook does not suppress the creation of the river entries (in database) but simply does not
        // display them (also no longer displays existing entries anymore) but as soon as you no longer use this
        // plugin hook all entries are displayed again
        elgg_register_plugin_hook_handler('view', 'river/object/comment/create', function (\Elgg\Hook $hook) {
            return false;
        });
        
        // this plugin hook results in the responses (comments) no longer being displayed together with the river entry
        // the comment was added to (e.g. a blog, file upload etc.). It's reversible, i.e. no longer using this hook
        // will display the responses again
        elgg_register_plugin_hook_handler('view', 'river/elements/responses', function (\Elgg\Hook $hook) {
            return "";
        });
    }
    
    function river_no_comment_entries(\Elgg\Hook $hook) {
        $returnvalue = (array) $hook->getValue();
    
        $action_type = elgg_extract('action_type', $returnvalue, 'no_comment');
        if ($action_type == 'comment') {
            return false;
        }
    
        return $returnvalue;
    }
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