How to prevent the updating of specific user fields

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 that has an “add_model_callback” and “:before_save” for some examples. And then you’d do it for UserProfile.

3 Likes