Hi, I have a customer who wants to display a custom badge in users profile.
I have to get the badge value in javascript from an external source, so I will call a function with the username as a parameter and this function will return a value for the badge.
Got it, I will add a new field in the database then I could create a script to populate that field. Then I will create a badge selecting this new field
You almost certainly don’t want to do that. You can use a user_custom_field (or maybe that’s what you meant, since it’s sort-of the same thing) or the similarly-named-thing in the user customization on the UX.
Understood. One last question, I searched sql queries for granting badges, and I couldn’t find an example who display a user_custom_field in the UI. They just look into the user_custom_field to grant the badge
For example in the screenshot I attached before, The number 105.230 should be stored in the user_custom_field and I need to display it in the badge
I’d have to look at the code to give you real answers.
What you want to do is have your plugin add that custom field to the serializer. You can search some existing plugins for add_to_serializer in plugin.rb for some examples. Then you can wrangle that into the badge on the front end.