How to prevent the updating of specific user fields

AI-generated summary

The discussion revolves around preventing the update of specific user fields in Discourse. IJK_Rick wants to ensure that certain fields, such as website or location, cannot be updated using methods like rails console, API, or dev tools, despite being hidden using CSS. merefield suggests writing a plugin to override the controllers, model, or library functions, while pfaffman notes that only admins have access to the rails console and proposes alternative solutions, such as writing a plugin to periodically set the fields to nil or using a hook to nil out the fields when the user profile is updated. IJK_Rick thanks the users for their answers and acknowledges that the measures may be overkill, but are required for the assignment.

There are certain user fields that I have hidden using CSS.
However they could still be updated using rails console, api or dev tools.
How do I ensure that nobody can update these fields (for example website or location) using aforementioned methods?

Write a plugin to change the API (ie override the Controllers, Model or the associated library functions)

This is very unlikely btw, only admins will get to the Rails console.

If you are hiding the display of these values, what does it matter if they fill them in? It would require some user contriving to add a location and another user would need to contrive to visit their profile and see what they had entered.

Short of forking Discourse to remove those fields from the model, there isn’t much way to keep someone with access to the rails console entering data in them.

You could write a plugin that would run periodically and set whatever fields you want to nil. Or you could have a hook that gets called when the user profile is updated that nils out those fields. Look for a plugin in GitHub - discourse/all-the-plugins · GitHub that has an “add_model_callback” and “:before_save” for some examples. And then you’d do it for UserProfile.

Thank you for your answers, will get it working with that. And I agree that it’s overkill to block to such an extent, but that’s the assignment.