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.

  • all the documentation I have seen implies that he field should display? just like plugin setting. it is not working that way for me.

  • I'v disabled ever other plugin.

  • the documentation also says radios and checkboxes wont work... Based on this example and my confidence that I have done this before, that statment in the docs is incorrect.

  • I had claude search the web, the docs, the core, and it couldnot figure it out either.

  • Do I actually need the user here? 

    Sure.

    This does not display on the setting form.

    Try run 'Upgrade' via administration to clean the caches.

     

  • Do I actually need the user here?  yeah that was dumb comment on my part.. So frusterated... I'v cleared the cache a million times, let me try manually deleting the cache dir. I'm affraid of upgrade It has blown me out to may times, my back up strategy is not ready for the disaster it could unleash RN.  Deleting cache did not help. Should the code I posted show if it is in the correct dir?

  • /views/default/plugins/amd_demo/usersettings.php

    This means that your plugin is called amd_demo.

    So your file should be here:

    /mod/amd_demo/views/default/plugins/amd_demo/usersettings.php

    Create a repository on GitHub and host your project there.

    This will help us understand what your problem is.

  • Yeah the field is in the correct location. I should expect it to show on the settings page?

  • It should be on '/settings/user/USERNAME' page under 'Configure your tools' section.

  • Thanks Nicolai, knowing what I should expect helped a lot.  The docs dont seem to mention all this either: 

        public function init() {
            // Additional initialization if needed
            $events = $this->elgg()->events;
            // Handle user settings save
            $events->registerHandler('usersettings:save', 'user', [$this, 'handleUserSettingsSave']);
        }
        public function handleUserSettingsSave(\Elgg\Event $event) {
            $user = $event->getParam('user');
            $request = $event->getParam('request');
    $enable_something = $request->getParam('enable_something');
    if ($enable_something !== null) {
                $user->setPluginSetting($this->plugin()->getID(), 'enable_something', $enable_something);
            }
            return null;
        }