WordPress.org

Ready to get started?Download WordPress

Forums

Next Gen Gallery Custom Fields auto scan / auto populate (5 posts)

  1. gillispj
    Member
    Posted 2 years ago #

    I created a web form using Quform to gather images and corresponding data from users. Using a custom PHP hook I have managed to point the images into the proper folders on the server. Using Next Gen Gallery and Next Gen Custom Fields I am creating galleries that are specific to each folder.

    Right now my problem is that I have to scan for images then manually enter the data gathered through the web form with the corresponding image.

    Is there a way to auto populate the gallery without having to scan for new images?

    Is there a way to auto populate the Custom Fields with the data gathered through the web form?

    Any help is appreciated!

  2. shauno
    Member
    Posted 2 years ago #

    Sure it's possible. But it's going to require custom code to be written no doubt.
    NGG and NGG Custom Fields offer APIs that you will be able to use to create the images and insert the relevant data. A little bit of code digging should sort it out.

  3. gillispj
    Member
    Posted 2 years ago #

    Hi Shauno- Thank you for your response.

    Would you kindly direct me to where I could start looking for these APIs?

    Thank You!

  4. shauno
    Member
    Posted 2 years ago #

    Um, the files inside the plugins :)

    Seriously though, NGG is pretty big, and I haven't poked around in a bit. I would start in the its admin directory, with functions.php and see what's there. Failing that, debug from the actual upload in the admin area.

    NGG Custom Fields APIs are pretty shitty in terms of abstraction, but it's a small code base, and you should be able to figure out the array format to nggcf_save_pics().

    The best way to figure things out it to step through them as they work currently. That should give you the info you need to write the code you need.

    Good luck

  5. gillispj
    Member
    Posted 2 years ago #

    Hi Shauno,

    Thank you for you response, I have run ragged trying to resolve this one. I do no have the PHP / MYSQL experience necessary to resolve this with our some serious help. I would really appreciate any ideas.

    If you are willing to take the time to look at this and give me any suggestions of how to make this hook work with your ngg_custom_fields.php

    How would I make this custom hook in my theme's functions.php sync with $pid

    //NGGCF DATABASE HOOK
    add_action('iphorm_post_process_12', 'mytheme_save_uploads', 10, 1);
    function mytheme_save_uploads($form)
    {
    // Get the submitted form values
    $firstname = $form->getValue('iphorm_12_1');
    $lastname = $form->getValue('iphorm_12_12');
    $permemail = $form->getValue('iphorm_12_3');

    // Check that a file was uploaded and save the URL
    $url = isset($upload[0]['url']) ? $upload[0]['url'] : '';

    // We will use the WordPress database class to connect to your custom database
    $wpdb = new wpdb('xxxxx', 'xxxxxx', 'xxxxxx', 'localhost');

    // this is where the problem is: I do not know how to these values also connect to $pid
    $wpdb->insert('wp_nggcf_field_values', array(
    'field_value' => $firstname,
    'field_value' => $lastname,
    'field_value' => $permemail
    ));

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic