How to remove comment option from ElggObject and from RiverActivity?? [Elgg 3.0]

I want to remove the comment option from my plugin. The comment option is appearing both in my plugin "all" page i.e. "elgg_list_entities" (Refer Figure 1 below) and also in the river activity "River plugin in Elgg 3.0" (Refer Figure 2 below).

Figure 1: All page of the plugin

Figure 2: Comment also appearing in river activity for my plugin

 

I want to completely remove the comment option from my plugin as shown below (Refer Figure 3)

Figure 3: No option to comment

 

I am not asking for the entire solution. Just refer me to any code sample or tutorial link or any reference point. I will find the rest.

Thanks in advance.

  • You might want to take a look at example 2 at http://learn.elgg.org/en/3.0/guides/menus.html#id4. I would think if you would remove the "comment" entity menu item (not sure if the menu item name is "comment" actually) for the entity type used in your plugin it should work.

  • Hi iionly, I did the testing using 'register', 'menu:entity' hook. Turns out that the menu:entity is for the menus inside the three dot.. like edit, delete etc.. comment is not falling inside the 'menu:entity' hook.

    I did a var_dump on both $menu and $item and found only 2 array.. one for edit and one for delete.

    Any other suggestion?

  • OK I was able to solve one of the comment option. When in "all" page i.e., elgg_list_entities, I was able to remove the comment, here's what I did:

    1. Created a class ElggMyObject extends ElggObject and created a function canComment inside the class that will return false.

    2. Added class as ElggMyObject in elgg-plugin.php file of my plugin.

    Done.. This solved comment option from all page as well as from activity page.

  • @Rohit Gupta

    elgg_unregister_plugin_hook_handler('register', 'menu:social', '_elgg_comments_social_menu_setup');
  • @RvR

    elgg_unregister_plugin_hook_handler will remove the comment block for all the plugins, I was asking only for one plugin.

  • I've not yet tested Elgg 3 much. It seems there's the new "social" menu where the "comment" menu entry is registered for. I would think you should be able to use the 'register', 'menu:social' plugin hook to unregister the "comment" entry for your entity type in the same way it you would do it with the register', 'menu:entity' plugin hook.

  • My advise is to use "container_logic_check" plugin hook to remove comments entirely in a certain subtype.