Custom user field that’s hidden from user and editable by API?

AI-generated summary

The discussion revolves around creating a custom user field that is hidden from users, editable only through the API, and not visible to users. Nerd_Alert seeks a solution to store a user’s computer hardware identifier without allowing users to see or edit it, in order to prevent them from logging into another user’s account.

Nerd_Alert plans to use this field to tie user accounts to specific hardware, preventing unauthorized access. pfaffman suggests hiding the field with CSS and editing it with an admin API key, or using a custom plugin.

An alternative solution proposed by JammyDodger is the User Notes plugin, which could be used to store the hardware identifier. However, Nerd_Alert is concerned about the need to manually create a note for each user. pfaffman clarifies that the User Note can be populated with the API, eliminating the need for manual creation.

is there any way to have a custom user field that is able to be edited through the api, that isn’t displayed anywhere to the user, and is in no way editable by the user?

I think that you’d make it not required at signup, hide it from the signup page with CSS and have it not be editable after signup. You could then edit it with an admin API key.

If the risk that a user might contrive to find the hidden field at account creation time then you’d need a plugin, I think.

Saying more about what you’re actually trying to do might be of use here. You’re proposing a solution here, and not the problem that it’s solving.

It’s not the perfect fit, but could you utilise the User Notes plugin?

I plan to use this to store the user’s computer’s hardware identifier, so users can’t login to another user’s account on the software (which is tied deeply into the forum). And I don’t want them to be able to see it (as it might give something away, not fully sure.) and I don’t want them to be able to change it so they can trick the system into allowing them to login into someone else’s account.

this would require me to manually enter one for each user, no?

I don’t quite understand how you’d do that, but you might check out DiscourseConnect to solve that problem. Or perhaps a custom plugin (if you’re self-hosted or on Enterprise) is what you’d want.

You could populate the User Note with the API the same as what you’d do with the API.

“You could populate the User Note with the API the same as what you’d do with the API.” - I was mainly asking if it would require me to like, create a note for each user. Also I already have a functioning implementation of the hardware identifier thing, I just need a way to store it and associate it with a user. And I know that you can get any user fields just by logging in as the user through the api.