Need two forms with the same dataset for Drone Operations.

By: Yves Carpentier | Asked: 03/29/2023
ForumsCategory: General questionsNeed two forms with the same dataset for Drone Operations.
Yves Carpentier asked 2 years ago
I have one form to enter missions for my drone pilots.  The admin needs to be able to enter new missions and update them.  so far no problem.  But then the subscribers, being the pilots of the company have to be able to update some fields and others should be read only.  So I need two different forms with the same recordset.  Thanks
2 Answers
Best Answer
Rob LeVineRob LeVine answered 2 years ago
Is it an option to have one form and use frm_setup_edit_vars to set fields to read-only?
Yves Carpentier replied 2 years ago

i am afraid not, as the form also has to be used by the administrator and in that case the fields also would be read only. so to my knowledge that would not be a sollution. To have two different forms would be very easy, but they have to be populated with the same dataset. Thanks anyway, have a nice day

Rob LeVineRob LeVine replied 2 years ago

I respectfully disagree. I use that filter all the time to set fields to read-only depending on various user metadata, including role. If your case, you'd replace/move "if ( FrmAppHelper::is_admin() )" in this example - https://formidableforms.com/knowledgebase/frm_setup_edit_fields_vars/#kb-set-fields-to-read-only-when-editing

Yves Carpentier replied 2 years ago

So, if I understand well, sorry i am a simple airline pilot not a real IT man. I use this:

add_filter('frm_setup_edit_fields_vars', 'frm_set_read_only', 20, 3);
function frm_set_read_only($values, $field, $entry_id){
// If on the back-end, keep fields editable
if ( FrmAppHelper::is_admin() ) {
return $values;
}

// If on front-end, make specific fields read-only
if ( in_array( $field->id, array( 1558,554,555,556 ) ) ) {
$values['read_only'] = 1;
}
return $values;
}

Then I suppose I have to change 20,3 by wich fields?
And of course 1558,554,... by fields I have to make read only.

Then when the user is Admin the fields will not be read only, but both users, admin and sybscriber are working on the frontend and somewhere i see //if on the back end ?????
Sorry, flying is easy 🙂 Thanks

Rob LeVineRob LeVine replied 2 years ago

There's no need to change 20, 3. 20 is the priority (don't worry about it) and 3 is the number of parameters that the function has.

You change 1558,554,555,556 to a list of fields you want to be read-only and they will show up that way for all users in the front end. If you want different fields to be read-only for different types of users, that will use the same function, but with different code.

As for flying, I'd prefer to go on believing that it's really hard.

Yves Carpentier replied 2 years ago

I inserted the snippet, but something must be wrong. When i open the website, its not working and i get a message above everything showing the text of the snippet. Need some help i am afraid to tell me how to insert the snippet, sorry
By the way, just out of currosity, where are you from? I am Belgian 🙂

Yves Carpentier replied 2 years ago

if you care to see it: my website is
https://www.flandersdrones.be/missions

Rob LeVineRob LeVine replied 2 years ago

I only know a handful of Dutch words, so... 🙂

I noticed that the code mentioned above is visible on the site, so that likely means it wasn't placed in the correct place. It needs to be in a code snippet plugin or functions.php and correctly wrapped with the PHP tags. See https://formidableforms.com/knowledgebase/formidable-hooks/

Yves Carpentier replied 2 years ago

I inserted as a shortcode in the page for subscribers, no error anymore but not working.Getting desparate, happy I have you

Yves Carpentier replied 2 years ago

nowi did it with inserting html code wrapped in php and it still does not work, sorry

Rob LeVineRob LeVine replied 2 years ago

I promise you that it works. If you send me a private message with both the following, I will take a quick look. 1. WP Admin id/pwd. 2. Link to or exact name of the form in question. 3. Exact steps for reproducing the issue.

Yves Carpentier replied 2 years ago

I dont kow how to send a private message here, but if you give me your email addres I will send you everything, thanks, or you can explain how to send a private message

Rob LeVineRob LeVine replied 2 years ago

To send a message you (oh so intuitively) hover over the Forums menu until something pops up and click the "Messages" button. A little easier than that is to send me an email at [email protected]

Walter JonesWalter Jones answered 2 years ago
Related to passing values from 1 form to another I would look here: https://formidableforms.com/knowledgebase/automatically-populate-fields/
Yves Carpentier replied 2 years ago

Thank, will give it a try if filter suggested by Rob does not work, or more realistyc if I can not make it work:-)

Yves Carpentier replied 2 years ago

Thanks, I will give it a try. Flying is very simple: push to go down, pull to go up :-)I suppose I enter the code with a plugin like wp-code. Have a nice day

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