Validate Custom User Field for Fediverse Handle

AI-generated summary

cogdog is seeking suggestions to validate custom user field input for Fediverse handles in the format @username@instance.name. Despite clear instructions, many users are entering invalid formats, such as email addresses, Twitter usernames, and random strings. Heliosurge suggested using the Discourse Authentication Validations plugin, which cogdog found useful. Additionally, Heliosurge recommended the User Field Prompt theme component to help correct invalid entries by providing format details and pictures.

Yes, I have searched and found one general method for validating the input to a custom user field. My skills here are a bit raw, so hoping for suggestions.

We’ve been encouraging people in our education community to include in their profile a username if they have a fediverse account (Mastodon, Bluesky, Threads, et al). These should be something with two @ signs, where the first is a username and the second a valid formatted domain.

 @coolperson99@someinstance.org

Despite what I thought was a clearly explained format:

The successful entry rate is like 20% or worse. I get email addresses, twitter usernames, random strings, URLs. I can only dream, but think it should be possible to check with some regex (again my skills are mid range to muddling) for the valid format.

This plugin maybe of interest if you’re self hosted or on a Hosted plan that includes it

This Customization > Theme component maybe also of interest as well. This of course can be installed on any discourse install.

Thanks Dan, the Discourse Authentication Validations plugin looks perfect and useful for my other fields.

I am already using Clickable Social Icon Links. I can see my mistake was asking for a mastodon username rather than a URL, so it looks like I have some cleanup to do!

You’re quite welcome!

Just found this Customization > Theme component that you might also find very useful.

You could create a post with fields that need correcting with providing format details/pic.