pods-framework / pods-gravity-forms

Integration with Gravity Forms plugin for WordPress (https://pods.io/gravityforms/)
https://wordpress.org/plugins/pods-gravity-forms/
GNU General Public License v2.0
62 stars 10 forks source link

pods GF submission isn't feeding into pods post type when form is displayed and submitted on the dashboard #64

Closed milesgwood closed 7 years ago

milesgwood commented 7 years ago

So I am trying to add a GF to the dashboard that feeds into pods. I used this code found here to display the form successfully.

function sh_dashboard_setup() {
    wp_add_dashboard_widget( 'sh_gf_dashboard', 'New Found Items', 'sh_gf_dashboard' );
}

function sh_gf_dashboard() {

    // Make sure the scripts are loaded
    // http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/functions/gravity_form_enqueue_scripts/
    gravity_form_enqueue_scripts( 3, true );

    // Render the form
    //http://www.gravityhelp.com/documentation/gravity-forms/user-guides/getting-started/embedding-a-form/
    gravity_form( 3, false, true, false, null, false );
}

screen shot 2017-04-27 at 2 01 16 pm

The form displays properly but upon submission it creates a new Post instead of feeding into pods and populating the custom fields. When the form is put into a regular page it feeds into the correct pod and creates the post I would expect it to.

I found another issue here that explained how to manually create the pod.. Using the code from that post I was able to manually create and populate the pod but I feel it should work without this code. I would like to display forms throughout my theme without having to manually create pods objects.

Here is my code for manually creating the pods object from the form submission.

//Getting the GF to connect to the POD manually
add_action( 'gform_pre_process_3', 'gf_3_mapping_config' );

/**
 * Map submissions from a GF form to a Pod
 *
 * @param array $form GF Form array
 */
function gf_3_mapping_config( $form ) {

    $options = array(
    'fields' => array(
        '15' => 'item_found_title', // GF field ID mapped to a pod field
        '11' => 'item_found_description',
        '14' => 'category',
        '8' => 'claimed',
        '9' => 'item_locations',

    )
);

    $pods_gf = pods_gf( 'item_found', 3, $options );

}
sc0ttkclark commented 7 years ago

Have you tried setting up the Pods feed itself from the form settings?

milesgwood commented 7 years ago

I did set up the Pods feed in the form settings. The feed works fine when I preview the form or place the form into a page. All of the correct fields connect to the correct Pods fields.

The problem occurs when I place the form on the dashboard. When the form is submitted from the dashboard, it creates a new basic post instead of feeding into Pods.

sc0ttkclark commented 7 years ago

Fixed by #67