Making read-only and hidden fields editable when updating a form as an admin.

By: Andre Larmet | Asked: 01/23/2025
ForumsCategory: General questionsMaking read-only and hidden fields editable when updating a form as an admin.
Andre Larmet asked 3 weeks ago

I have a user profile form that contains 2 read-only fields and one hidden field. As the admin, I bring up the form in a page for edit purposes. The read-only fields are showing up as read only and the hidden field is not showing up. I thought that by using some php code, I could make those fields editable by changing the type to "text". This is the first time I am trying to use php code and snippets in Fforms and I am lost as to how it all works. What I have as a snippet in WPcode plugin: I used a sample snippet used to hide fields and changed it to what I thought would do the reverse operation. add_filter('frm_field_type', 'change_my_field_type', 10, 2); function change_my_field_type($type, $field) { echo 'got here'; if(in_array($field->id, array(67,121,125))) { //fields 67,121,125 should now be text fields and editable   if(is_admin())//if current user is admin echo 'got here'; $type = 'text'; //show the fields   }   return $type;   I put an echo statement to see if the code is even run.   The question is How and Where do I invoke this code in my form?   I have contacted tech support but they don't seem to understand my question. They keep pointing me to the same docs that I have read over and over without finding the answer to my question. I am not asking to have code written for me, I am asking how to use, invoke, trigger the code within the Fforms framework.   Any insight is appreciated   Andre  

1 Answers
Bobby Clapp Staff answered 3 weeks ago

How the code runs is going to be dependent upon how you've set it up in WPcode:


https://wpcode.com/docs/run-code-snippets-on-demand/


The code snippet needs to be active and probably set as shown in the first image in step 2.

Andre Larmet replied 3 weeks ago

Thanks Bobby

You put me on the right path with your answer and I am now able to "trigger" (for lack of a better word) the code on my form although it crashes the page.

2025-01-24T22:18:55+00:00 Cannot redeclare MakeFieldsEditable() (previously declared in /home2/czekskmy/public_html/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.php(419) : eval()'d code:2)

But that's another meeting...

Thanks again!!!

Andre

Victor Font Staff replied 3 weeks ago

That error means that you are somehow declaring the function twice.

Andre Larmet replied 3 weeks ago

Yes, that was the case. Found where and fixed it.

Thanks for the reply

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