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
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
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
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.
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 🙂
if you care to see it: my website is
https://www.flandersdrones.be/missions
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/
I inserted as a shortcode in the page for subscribers, no error anymore but not working.Getting desparate, happy I have you
nowi did it with inserting html code wrapped in php and it still does not work, sorry
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.
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
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]
Thank, will give it a try if filter suggested by Rob does not work, or more realistyc if I can not make it work:-)
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
Please login or Register to submit your answer