Save plugin settings

I have written my own plugin. Now i want to save some plugin settings. The form with the settings is ready and does work.

But now I want to write my own save action. In the standard save.php of elgg there is this code:


// allow a plugin to override the save action for their settings
if (elgg_action_exists("$plugin_id/settings/save")) {


I created the folder mod/my_plugin/actions/my_Plugin/settings/save.php. I also tried it with a folder .../settings/save/save.php. But nothing does work.

Has anybody an idea, where i have to create the folder and my save.php that it works?

  • 1. You can set your options on the plugin's settings page and call them in your views:


    $entity = elgg_extract('entity', $vars);
    echo elgg_view_input('text', [
        'name' => 'params[my_option]',
        'label' => elgg_echo('my_option:name'),
        'value' => $entity->my_option,

    some file:

    $plugin_option = elgg_get_plugin_setting('my_option', 'my_plugin');
    //Use echo if ...

    2. Or learn how to register action

  • I think it's not the location of the action but the name of the action that is important here. You need to register the action in the init function of start.php with the action name "my_plugin/settings/save", e.g.

    $base_dir = elgg_get_plugins_path() . 'my_plugin/actions';
    elgg_register_action("my_plugin/settings/save", $base_dir . "settings.php", 'admin');

    and then you can place the save action file where you want it (i.e. somewhere in the actions folder of your plugin) as long as the second parameter of elgg_register_action() gives the correct path to the action file.

  • Thanks for your answers. Now it works.

    The problem was, that I wrote the wrong paths in my elgg_register_action.

    Thanks for helping.

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