customize blog plugin

I have a plugin and would like to override the  save.php action located in the blog module at: 

/var/www/html/vendor/elgg/elgg/mod/blog/actions/blog

Can you override this action in the same manner as overriding a core action since it's part of a module?  Register the action in my start.php with path:

/var/www/html/mod/my-plugin/mod/blog/actions/blog/save.php?  I don't want to recreate the blog just update that action.

  • Can you override this action in the same manner as overriding a core action since it's part of a module? 

    Sure.

    Elgg 2.x: http://learn.elgg.org/en/2.3/guides/actions.html#registering-actions

    Elgg 3.x: http://learn.elgg.org/en/3.x/guides/actions.html#registering-actions-using-plugin-config-file

    You custom action must be located in:

    /mod/my_plugin/actions/blog/save.php
  • So I've added to my start.php: 

    elgg_register_action('mod/blog/actions/blog/save', __DIR__ . '/actions/blog/save.php');

    and added some system_message statements at the beginning of my action file to display when this action is triggered but doesn't seem to be recognizing my file.  I've also tried to modify the core action located in my elgg installation directory at:

    /var/www/html/vendor/elgg/elgg/mod/blog/actions/blog/save.php

    added some system_message statements when I know the blog post saved successfully like:

    system_message(elgg_echo('blog:message:saved'));

    system_message('custom message');

    but, my custom message never printed so I'm not sure why even my changes in the core action aren't being recognized.  Seems like I'm overlooking something simple here... but haven't yet figured it out.

  • Please read the documentation on how to correctly register an action.

    it should be

    elgg_register_action('blog/save', __DIR__ . '/actions/blog/save.php');
  • Thanks Jerome.. I did read the docs but I was a little confused about how to override an action that is part of a bundled plugin.  I wasn't sure if it was the same as registering a new action from scratch.