Support » Plugin: NextGEN Custom Fields » [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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author shauno


    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?

    Hi Shauno, thanks for the response – I read this post:

    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


    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.