Defino un nuevo campo personalizado de usuario:
User.find_each do |user|
user.custom_fields['foo'] = 0
user.save_custom_fields
end
Eso funciona, ahora cada usuario tiene 8 campos personalizados:
[18] pry(main)> User.find(1).custom_fields
=> {
"patreon_id" => "83297319",
"last_chat_channel_id" => 32,
"last_digest_special_post" => "275200",
"last_digest_favorite_post" => "279347",
"example_field" => "new value",
"ai_bot_query_count" => "0",
"ai_bot_query_date" => "2025-01-12",
"foo" => "0"
}
Data Explorer ve el nuevo campo:
SELECT * from user_custom_fields
WHERE name LIKE '%foo%'
LIMIT 10
Ahora quiero usar el campo ‘foo’ en javascript. Agrego algo de código en /admin/customize/themes/3/common/head_tag/edit. Pero solo aparecen 2 de los 8:
api.getCurrentUser().custom_fields
{
last_chat_channel_id: 32,
ai_bot_query_count: '0'
}
¿Qué me estoy perdiendo?
Moin
12 Enero, 2025 14:51
2
¿Añadió sus campos de usuario a la configuración del sitio campos de usuario personalizados públicos?
This guide explains how to expose user custom field data through the API without displaying it on a user card.
Required user level: Administrator
This guide will walk you through the process of making User Custom Field data accessible via the API without displaying it on a user card. This can be useful when you need to programmatically access custom user data while keeping it hidden from general view.
Creating a User Custom Field
First, create your User Cu…
2 Me gusta
Gracias, eso funcionó.
Una pregunta más: ¿son estos campos de usuario personalizados algo diferente?:
This guide explains how to create and configure custom user fields in Discourse, including how to add them to the signup form, user profiles, and user directory.
Required user level: Administrator
Custom user fields allow you to collect additional information from your users beyond the standard profile fields. These fields can be displayed on user cards, user summary pages, and even retrieved using the Data Explorer plugin. This guide will walk you through th…
system
(system)
Cerrado
11 Febrero, 2025 15:05
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.