override comment/save

I'm using Elgg 2.3.14 and need to override and comment/save action.  I currently have a copy of the core comment/save.php located in my plugin directory which is /var/www/html/fc-plugin/actions/comment/save.php.  I've added some custom 'system_message" strings in my plugin file near the beginning of the page to make sure they print out.  I also added a 'system_message' line in the core ../actions/comment/save.php.  The result that I'm seeing now when posting a comment is that I see the text I print in the core save.php and not my plugin save.php.  Isn't this the correct way to override a core action file?  What am I doing wrong here?

  • Did you add your action in start.php of your custom plugin:

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

    Read more.

    Did you add your custom 'system_message" strings in your languages/en.php?

    Read more.

    Flush the caches is required.

  • Ah.. simply forgot to register it.  That was an oversight... thanks!

  • The custom messages that I need to print will be based on what comes back from a curl rest call.  I'm trying to make sure I'm getting back the data I expect and wanted to simple display the json data that is returned.

    $result = curl_exec($curl);


    $json = json_decode($result, true);

    system_message('name is: '. $json->name );

    This currently prints: 'name is:  ' 

    The data for the curl was run in Postman with results so I believe the setup is correct.  I even tried to just create an arbitrary json object with fake data to try to print that the same way, but that failed as well.

  • I don't know what you try to do but the JSON output may be also as:




    or even:


    Learn more: https://www.json.org/example

    Also, you can check it:

    echo $json->name;

    or full output:

  • Got it working.  Thanks.