adding setting to the user settings page.

I hate to be that guy, who only shows up when he's upset.... but .... this flat out does not work in 5.. It does not save the data from my form field, it does not include or display the field, unless registered as an extension.. Can anybody please explain this correctly, the documentation does not.

User settings

Your plugin might need to store per user settings too, and you would like to have your plugin’s options to appear in the user’s settings page. This is also easy to do and follows the same pattern as setting up the global plugin configuration explained earlier. The only difference is that instead of using a settings file you will use usersettings. So, the path to the user edit view for your plugin would be plugins/<your_plugin>/usersettings.php.

Note

The title of the usersettings form will default to the plugin name. If you want to change this, add a translation for <plugin_id>:usersettings:title.

  • You just need to get the user and his current user settings.
    Then add form fields.

    Submit is not needed.

    Everything will do this action.

    Just look at the code example.

  • Ok so as i understand I should be able to add usersetting.php file with a form field on it and that shoulld show on the user settings page?

  • so this echo elgg_view_field([ '#type' => 'checkbox', '#label' => elgg_echo('settings:is:making:me:furious'), 'name' => 'params[enable_something]', 'default' => 0, 'value' => 1, 'checked' => (bool) $user->getPluginSetting('amd_demo', 'enable_something'), ]); is not displaying.

  • so this echo elgg_view_field([ '#type' => 'checkbox', '#label' => elgg_echo('settings:is:making:me:furious'), 'name' => 'params[enable_something]', 'default' => 0, 'value' => 1, 'checked' => (bool) $user->getPluginSetting('amd_demo', 'enable_something'), ]); is not displaying.

  • BTW I made a double submit plugin a long time ago that works way better that the built in one. 

  • The form field does not show unless I register it in elgg-plugin.php. Should it display without registering it?

  • In the example shared there is no views/default/plugin dir. That it is not consistent with the documentation. This is not helping.

  • The form field does not show unless I register it in elgg-plugin.php. Should it display without registering it?

    Form fields are not registered in elgg-plugin.php. They must be added to the form and displayed there.
    Exception form:prepare:fields event

    In the example shared there is no views/default/plugin dir. 

    File is located at /mod/activitypub/views/default/plugins/activitypub
    /usersettings.php

    Otherwise my plugin wouldn't work properly :)

  • Yeah my bad, somehow while navigating the files I keep finding my self in the core. I think I'm loosing it because this is so frusterating.. The documentation is terrible.

  • So I have this at /views/default/plugins/amd_demo/usersettings.php,  <code>

    $user = elgg_get_logged_in_user_entity();

    echo elgg_view_field([
        '#type' => 'checkbox',
        '#label' => elgg_echo('settings:is:making:me:furious'),
        'name' => 'params[enable_something]',
        'default' => 0,
        'value' => 1,
        'checked' => (bool) $user->getPluginSetting('amd_demo', 'enable_something'),
    ]);

    </code>

    Do I actually need the user here? 

    This does not display on the setting form.