Populate hidden field with database value
Author | Posts |
---|---|
March 1, 2014 at 11:12 pm 16039 | |
Tareq Hasan | I am trying to come up with a way to "lock" the post title and content fields on a form so that the data is not changed. I am using one form to add new posts and that form has normal fields. However, on the edit form I don't want the user to change anything except the post tags. I am trying to make the form save the record with only the tags changed? What, exactly, should I type into the hidden field so that it maintains the current value in the data base. Whatever I enter is saved as a text entry (i.e. the text "post_title") and not the db value. Or if I need to add a function to functions.php, please share the code with me that does this. I would greatly appreciate your help as I have been trying to sort this out for several days now. Thanks! |
March 2, 2014 at 3:37 am 16041 | |
Tareq Hasan | May be you can make the post title and the post content as a read only field by using jQuery/JavaScript. That way they wouldn’t be able to update those fields. I haven’t tried it yet, when I do, I’ll post the codes here. |
March 2, 2014 at 7:51 pm 16058 | |
ProUser | THANK YOU, Tareq! That would be greatly appreciated as I am not familiar with JavaScript coding and and I’ve been struggling to resolve this for about a week…. The ability to allow registered users to add tags to other author’s post/images but no other fields. I feel I am spinning in circles looking for ways to accomplish this. 🙂 |
March 3, 2014 at 12:47 pm 16096 | |
Tareq Hasan | Paste this code in your themes [php] add_action( ‘wpuf_edit_post_form_bottom’, ‘wpufe_lock_post_fields’ ); Change the form ID in that code with your form id. Note: It’ll not work if the post content field has rich textarea. |
March 4, 2014 at 4:32 am 16120 | |
ProUser | Thank you for the javascript snippet. It worked beautifully. One last, unexpected problem with this. I made an assumption that I would be able to lock the image upload and featured image fields the same way but have been unsuccessful. Could you please tell me how to do that? I’ve been trying all day and no luck (except bad) :(. Many thanks to you again. |
March 4, 2014 at 2:39 pm 16135 | |
Tareq Hasan | I think you can’t disable the image field with this, sorry! |