Title: [Plugin: NextGEN Custom Fields] Populating Custom Fields from PHP
Last modified: August 20, 2016

---

# [Plugin: NextGEN Custom Fields] Populating Custom Fields from PHP

 *  [phobic](https://wordpress.org/support/users/phobic/)
 * (@phobic)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-populating-custom-fields-from-php/)
 * Hi there!
 * I’m using the popular combo of NextGenGallery/NGG Public Uploader/NGG Custom 
   Fields, and they all work extremely well.
 * I’m interested in creating the functionality to have the Public Uploader automatically
   populate two custom fields on successful upload – one being the current user’s
   username, the other being the slug name of the page.
 * I have an idea of roughly how this should work, but I’m struggling writing it
   from scratch. If anyone has any pointers, it’d be massively appreciated.
 * Thanks in advance!
 * [http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/](http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/)

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

 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-populating-custom-fields-from-php/#post-2698501)
 * Hi phobic
 * People have asked about integrating this before. I even contacted the author 
   of NGG Public Uploader and asked if he was interested in making it possible by
   adding some hooks. Unfortunately, he never responded.
 * I have looked into the public uploader code before, and without ‘hacking’ it 
   a little, it’s not going to happen.
 * That being said, writing a custom solution is possible. The structure of the 
   NGG Custom Fields stuff is pretty straight forward if you’re comfortable with
   that sort of stuff.
 * Is there anything specific you’re stuck on?
 *  Thread Starter [phobic](https://wordpress.org/support/users/phobic/)
 * (@phobic)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-populating-custom-fields-from-php/#post-2698502)
 * Hi Shauno, thanks for the response – I read this post:
 * [http://wordpress.org/support/topic/plugin-nextgen-custom-fields-use-with-nextgen-public-uploader?replies=13](http://wordpress.org/support/topic/plugin-nextgen-custom-fields-use-with-nextgen-public-uploader?replies=13)
 * So I understand it’s not a quick code tweak. I’m actually using the modified 
   Public Uploader file from that thread by ‘simoneast’, and it gets me really close–
   it adds two fields to the uploader form and sends the information to the ‘description’
   field split in two lines. Now I just need to send the information to the two 
   custom fields I created using NGG Custom Fields.
 * My PHP is weak, but it looks like this line is what posts the information to 
   the description field:
 *     ```
       // Combine other fields into description
       			$_POST['imagedescription'] = $_POST['uploader_name'] . "\r\n" . $_POST['uploader_email'] . ' [' . $_POST['receive_updates'] . ']';
       ```
   
 * I’m assuming I can just replace the field names with my custom field names? Can
   it be that simple?
 *  Plugin Author [shauno](https://wordpress.org/support/users/shauno/)
 * (@shauno)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-populating-custom-fields-from-php/#post-2698504)
 * That does seem to save the info into description. But adding custom fields is
   a little more complicated cause they are completely separate from the NGG core.
   
   An oversimplified version of flow would be:
    - Add the image to NGG (I guess this is happening already)
    - Get the custom fields’ id from `wp_nggcf_fields`
    - Insert the `pid`, `fid`, and `field_value` into `wp_nggcf_field_values` (setting`
      ngg_type` to 1 for images
 * That’s the theory, but I haven’t actually looked at the code in awhile to tell
   you where to go about it. You obviously will need to be comfortable SELECTING
   and INSERTING data with the WP DB wrapper.

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

The topic ‘[Plugin: NextGEN Custom Fields] Populating Custom Fields from PHP’ is
closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/nextgen-gallery-custom-fields.svg)
 * [NextGEN Custom Fields](https://wordpress.org/plugins/nextgen-gallery-custom-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery-custom-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery-custom-fields/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [shauno](https://wordpress.org/support/users/shauno/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-nextgen-custom-fields-populating-custom-fields-from-php/#post-2698504)
 * Status: not resolved