I define a new user custom field:
User.find_each do |user|
user.custom_fields['foo'] = 0
user.save_custom_fields
end
That works- now each user has 8 custom fields:
[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 sees the new field:
SELECT * from user_custom_fields
WHERE name LIKE '%foo%'
LIMIT 10
Now I want to use the foo field in javascript. I add some code at /admin/customize/themes/3/common/head_tag/edit
. But only 2 of the 8 show up:
api.getCurrentUser().custom_fields
{
last_chat_channel_id: 32,
ai_bot_query_count: '0'
}
What am I missing?
Moin
2
Did you add your user fields to the public user custom fields
site setting?
1 Like
Thanks, that did the trick.
One more question- are these custom user fields a different thing?: