Git Product home page Git Product logo

Comments (10)

sc0ttkclark avatar sc0ttkclark commented on June 15, 2024

@naomicbush @Shelob9

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Hi guys,

Thanks for your work on this.
I am developing a project where this will be very helpful, but I was hoping you could provide me a bit more guidance on where and how I would implement the above code.

I have a Gravity Form created to capture all the fields related to a new “B&B Visitor”, and I have created a “B&B Visitor” Custom Post Type in Pods with matching fields. I now need to connect them so that when my Gravity Form is submitted, it creates a “B&B Visitor” Custom Post with the information from the Gravity Form.

I understand some of what I am reading in your text above, but I am not clear on where I need to call the action, and where/how I need to define your_gf_mapping_config.

If you could give me an overview of how this would be implemented, and what code would go in which files, it would really be appreciated. You could assume the Gravity From in question is Form ID #1 and the fields in question are just fields #5 and #6 (which I want to map to the "fields first_name" and "last_name" in a new “B&B Visitor” Custom Post)

Thanks so much in advance.

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Hi again. Just wondering if anyone has a status on this. I have not gotten far on my own so if a GUI will be forthcoming I will stop my attempts and just be patient. Thanks again for all the great work, a donation was sent earlier today.

from pods-gravity-forms.

sc0ttkclark avatar sc0ttkclark commented on June 15, 2024

I'll work on a reply for this tonight in my late night dev run.

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Thanks Scott, much appreciated.

from pods-gravity-forms.

sc0ttkclark avatar sc0ttkclark commented on June 15, 2024

In your theme functions.php or in a plugin file, place the code example above and adjust as needed. Specifically:

add_action( 'gform_pre_process_{form_id}', 'your_gf_mapping_config' );

That's the type of thing needed here, which you'll probably only want to target if ( !is_admin() ) in your function.

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

    // Don't hook in the admin area, unless you need it
    if ( is_admin() ) {
        return;
    }

    $options = array(
        'fields' => array(
            '5' => 'first_name',
            '6' => 'last_name'
        )
    );

    $pods_gf = pods_gf( 'b_b_visitor', $form_id, $options );

}
add_action( 'gform_pre_process_1', 'github_greg_pods_to_gf' );

Please let me know how that works for you.

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Thanks for taking the time Scott, you are too kind. I will let you know how it goes!

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Thanks again for your help Scott.

Initially it didn't work (the gravity form submitted, but no pod post got created). However, I found that if I hard-coded the $form_id value within the pods_gf function call as follows...

function github_greg_pods_to_gf( $form ) {
    ...
    $pods_gf = pods_gf( 'b_b_visitor', '6', $options );
}
add_action( 'gform_pre_process_6', 'github_greg_pods_to_gf' );

...then it would actually work and create the pod post, but would also return this PHP warning:

Warning: Invalid argument supplied for foreach() in /plugins/pods-gravity-forms-master/includes/Pods_GF.php on line 2878
Warning: Invalid argument supplied for foreach() in /plugins/pods-gravity-forms-master/includes/Pods_GF.php on line 1298

Perhaps it's a simple thing I am not seeing.

from pods-gravity-forms.

sc0ttkclark avatar sc0ttkclark commented on June 15, 2024

Fixed the warnings, they were the issue.

from pods-gravity-forms.

GitHubGreg avatar GitHubGreg commented on June 15, 2024

Once the pod item gets created from the gravityform entry, how would I get the ID of the pod item that was created?

$pods_gf->?

Thanks

from pods-gravity-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.