# Plugin to validate a text type custom field value

**URL:** https://meta.discourse.org/t/plugin-to-validate-a-text-type-custom-field-value/325534
**Category:** Development
**Created:** [September 8, 2024, 7:36pm UTC](https://meta.discourse.org/t/plugin-to-validate-a-text-type-custom-field-value/325534 "2024-09-08T19:36:29Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![omegerard](https://avatars.discourse-cdn.com/v4/letter/o/f9ae1b/32.png) [@omegerard](https://meta.discourse.org/u/omegerard)
#### Post date: [September 9, 2024, 7:40pm UTC](https://meta.discourse.org/t/plugin-to-validate-a-text-type-custom-field-value/325534/2 "2024-09-09T19:40:17Z")

</div>

I know for sure that this piece of code is what causes the 500 Internal Server Error:

> [@omegerard](#):
>
> `user_field_value = self.custom_fields[custom_field_key]`

Is there anybody out there who can tell me how to get at the user field value of a custom field?

Other peices poeces of code that aren’t workijg either:

```plaintext
custom_field_value = self.user.reload.custom_fields[custom_field_key]

```

```plaintext
custom_field_value = UserCustomField.where(user_id: self.user.id, name: custom_field_key).pluck(:value).first

```

Any ideas / pointers to documentation pr code?

---

_[View the full topic](https://meta.discourse.org/t/plugin-to-validate-a-text-type-custom-field-value/325534)._
