Change Field from Read-Only to Editable Based on User Role

By: Nicola Gammarrota | Asked: 06/01/2025
ForumsCategory: Code SnippetsChange Field from Read-Only to Editable Based on User Role
Nicola GammarrotaNicola Gammarrota asked 2 weeks ago

Hi there,
I’m working on a form where I need to make a specific field either read-only or editable depending on the user’s role.
More specifically, I have a field (e.g., “Department/Service”) that should:

  • Be read-only for most users (e.g., um_gas, um_formazione, etc.)
  • But be editable for users with higher privileges, such as the roles administrator or um_tesoriere

 
Is there a built-in way (or a recommended custom JavaScript/jQuery or PHP approach) to dynamically change the readonly state of a field based on the user role?
I’m currently using Ultimate Member alongside WordPress roles, so users may have multiple roles assigned (e.g., author, um_gas). Ideally, I would like to check whether the current user has one of the “allowed” roles and, if so, enable the field for editing.
Any suggestions or examples would be much appreciated!
Thanks in advance!

2 Answers
Best Answer
Nicola GammarrotaNicola Gammarrota answered 2 weeks ago

Thanks, it worked!

Victor Font Staff answered 2 weeks ago

Use the frm_setup_new_fields_vars and frm_setup_edit_fields_vars hooks like this: https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/#kb-make-field-read-only-for-non-administrators

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right