Title: Update / alter field values from code
Last modified: August 20, 2016

---

# Update / alter field values from code

 *  Resolved [IoanPokorny](https://wordpress.org/support/users/ioanpokorny/)
 * (@ioanpokorny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/update-alter-field-values-from-code/)
 * Hi, sorry to be bothering again, I really enjoy your plugin and it’s helping 
   a lot on my projects.
 * I have a question though, is there a way, existing function, code or anything
   so I can alter field values from the php file.
 * for example as there is the $atachments->field(‘ANY_FIELD’) function to return
   the value for that specific field, I need to be able to complete my project to
   be able to change the value of a given field from php code ( field(‘field_here’)
   =’my_value’).
 * How could I be doing this?
 * Thanks
 * [http://wordpress.org/extend/plugins/attachments/](http://wordpress.org/extend/plugins/attachments/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Jon Christopher](https://wordpress.org/support/users/jchristopher/)
 * (@jchristopher)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/update-alter-field-values-from-code/#post-3345695)
 * That seems like a strange use case for Attachments to be honest. It sounds like
   you’re trying to get around your issue of needing to dynamically set a field 
   value based on something else your users are doing. I would suggest not using
   an Attachments field for this since they are intended to be manually populated
   by users and instead set up your own (hidden) post meta key that manages this
   field for you.
 *  Thread Starter [IoanPokorny](https://wordpress.org/support/users/ioanpokorny/)
 * (@ioanpokorny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/update-alter-field-values-from-code/#post-3345712)
 * I just want to be able to store some values in the fields
 * I have made this function
 *  function fute($name, $valoare)
    { $this->attachments[$this->attachments_ref]-
   >fields->$name=$valoare;
 *  }
 * if I call it as fute(‘field_name’, ‘value’), it stores the new field value and
   if I echo that field using your standard function it displays me the new value.
 * The single problem would be what to do so I can store the new value in the database
 *  Thread Starter [IoanPokorny](https://wordpress.org/support/users/ioanpokorny/)
 * (@ioanpokorny)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/update-alter-field-values-from-code/#post-3345783)
 * I need to dinamicaly populate a field of an attachment to set a value based on
   an activity a user does so I know it has been claimed by somebody.
 * The only thing I would need for you is to let me know how to save the the value
   from the above function or do it another way if it’s appliable, not sure what
   else I could use as I need that field for any individual attachment.
 * I really appreciate your work and it helps me a lot, I noticed that the premium
   version is not available, I can make a financial support to help you carry on
   with development but I really would need to be able to do that as your plugin
   offers exactly what I need and as it’s displayed using PHP I can arrange it in
   the exact layout I needd.
 * Thanks,
    Ioan

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Update / alter field values from code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/attachments_fafafa.svg)
 * [Attachments](https://wordpress.org/plugins/attachments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/attachments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/attachments/)
 * [Active Topics](https://wordpress.org/support/plugin/attachments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/attachments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/attachments/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [IoanPokorny](https://wordpress.org/support/users/ioanpokorny/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/update-alter-field-values-from-code/#post-3345783)
 * Status: resolved