Disabling full name changes

Hi,

I have just begun operating a small discourse for real life friends and I wanted to enforce a Real Name policy.

I’ve required full name on sign up and an approval only policy, but after sign up users can edit their Full Name. I want to disable this so that an approved user’s full name is essentially locked after sign-up, but an admin can still edit the field.

I was looking at where this check happens and it seems there’s no logic that will let me enforce this policy exactly:
https://github.com/discourse/discourse/blob/e8c7c6fab7b47d5a5c4f14bcfbe0f7312ed3e6cc/lib/guardian/user_guardian.rb#L22

Username and e-mail have settings that relate to whether a user can self-edit them, but there are no such settings for full names. Is this true? Is there some work around?

Thanks!

3 Likes

I have an instance where avatars are handled elsewhere and I changed the preferences template to hide the avatars change section. You can do the same.

2 Likes

I see. That seems like a clean solution.

Was the separate avatar handling page a custom page you’ve added?

Yes, I changed the preferences template, so the little pencil from avatar on preferences page is a link that send people to the avatar change page in another system. Our avatars were handled outside Discourse and integrated with the setting default avatars.

Thanks I think that gives me an idea of how I might proceed.

Interesting. I have a similar requirement for a Membership site.

In my case we will carry over Real Names from a separate site with registration using SSO. We will allow users to adopt usernames for taking part in the Discourse conversation, but we want them to always be linked to a Real Name on their profile, and so do not want them to be able to change it once it has been populated during registration.

Is this possible?

Since you’re using SSO, checking sso overrides name should solve your problem :slight_smile:

4 Likes

thanks! I’m not yet using … but it is the plan I am putting together and so have not discovered that yet. Much obliged

2 Likes

I’ve been searching 20 minutes and can’t find the preferences template. I’ve found pieces of it but not the template. Can someone point me to it?

I think the template is referring to this part of the codebase

This portion specifies the action that gets taken when someone clicks on the big pencil for editing the avatar.

https://github.com/discourse/discourse/blob/42f6c9b6b9db81e2a6a9ca45e76f067980525f67/app/assets/javascripts/discourse/app/templates/preferences/account.hbs#L24

& here is the action associated with the showAvatarSelector that could be replaced if you wanted to customize.

Hope this helps!

5 Likes

Thanks, but I believe @Falco may have been referring to Admin > Customize > Text. For example I can find this piece:

js.user.change_avatar.title

and I expected there would also be a higher-level template that defines the entire user’s preference page and contains that piece. By removing the avatar section from that template, one could prevent users from changing their avatar. (Or their full name, which is what I want to do.)

But I still can’t find the template that defines the users preference page.

No, what I meant is exactly what @weallwegot referenced. You can learn how to overwrite templates reading Developer’s guide to Discourse Themes

3 Likes