This plugin demonstrates how to add a custom setting to users, that is later passed back to current user (meaning you will have access to it on every page load)
- It adds a user preference to disable “replaceState” during topic navigation.
- It ensures the setting is shipped to clients with Discourse.User.current().
Important API notes:
custom_fields to be serialized with current user use:
DiscoursePluginRegistry.serialized_current_user_fields << "my_field"
To specify a type for a custom field use:
after_initialize do User.register_custom_field_type('my_field', :boolean) end
It can be used to keep browser history less cluttered.