PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

integrate wp affiliate platform for pay per lead commission

  1. rovillesarate
    Member

    Hi! Guys is there a way to do this script with in gravity forms hook for pre-submission? i want to reward a pay per lead action using wp affiliate platform.

    They used this script on contact 7 additional settings to award the commission. "on_sent_ok: var url='http://www.shadow-labs.com/wp-content/plugins/wp-affiliate-platform/api/post.php?data=4bd39e2e4a7ty|'+getCookie('ap_id')+'|49.95||2'; ajax.gets(url);"

    they award commission can be awarded using http post request but I dont want to redirect users to that page;

    Is there a way to post submit this query over pre-submission hook?

    Posted 14 years ago on Thursday October 14, 2010 | Permalink
  2. Why would you need to use a hook? Isn't this Javascript?

    Can't you just place it in either the Form Description field, an HTML block field on the form and then if you need script on the Thank You page on the Form Confirmation text or on a custom Thank You page the form redirects to? You shouldn't have to use a hook to do this.

    The hooks are for manipulating form data, not for executing Javascript in situations like this.

    Posted 14 years ago on Thursday October 14, 2010 | Permalink
  3. AxellOnline
    Member

    I am not sure if rovillesarate figured out a solution but I am trying to do something similar with the WP Affiliate Platform.

    Below I have a link to the directions and code they want added to contact form 7. Basically they want you to add some shortcode to the notification. Done (note: not sure if shortcode will work) Then they want you to add the code into a file of the plugin. The code is supposed to go in to the plugin right before it composes the email that it sends to the admin.

    My question is where in GF plugin should I paste in this code.

    Any and all help will be appreciated. Thank you.

    Background
    These are the directions that they tell you to use on contact form 7
    http://www.tipsandtricks-hq.com/wordpress-affiliate/how-to-capture-leads-using-the-wp-affiliate-platform-215

    This is code they want you to add to the classes.php file in contact form 7
    http://www.tipsandtricks-hq.com/wordpress-affiliate/wp-content/uploads/lead-capture-contact-form-code-modification.txt

    Posted 14 years ago on Friday November 5, 2010 | Permalink
  4. AxellOnline
    Member

    This is what the ppl at Tips and Tricks said
    "Essentially it is a contact form plugin so it should be doable but because gravity forms is a premium plugin we can't just start hacking that plugin.
    We just need a hook that allows us to execute a bit of PHP code after the "Submit" button is clicked on the form. Maybe Gravity forms has an option to do this.

    Can you please ask the gravity form guys if they have an option where we can add an action or hook so that when the "Submit" button is clicked on the form it will send us the submitted info to our action function? This will allow us to capture the lead after someone hits the "submit" button on the contact form."

    Posted 14 years ago on Monday November 8, 2010 | Permalink
  5. Gravity Forms does have a hook that fires after the "submit" button is pressed and the form passes validation. Following is a code snippet of how to use this hook. It should be placed in your theme's functions.php field

    add_action("gform_post_submission", "gf_post_submission", 10, 2);
    function gf_post_submission($entry, $form){
    
        // ADD YOUR CODE HERE
    
    }
    Posted 14 years ago on Monday November 8, 2010 | Permalink
  6. AxellOnline
    Member

    I just added the hook above and included the code from tips and tricks, but now the notifications are no longer sent to the admin and the leads are still not being logged in the affiliate software. Here is what the code looks like :

    <script src='http://pastie.org/1288363.js'></script>

    Posted 14 years ago on Wednesday November 10, 2010 | Permalink
  7. AxellOnline
    Member

    The admin notifications issue has been fixed with the install of wp-mail-smtp but I still have not gotten the leads to show up in the Affiliate software

    Posted 14 years ago on Thursday November 11, 2010 | Permalink
  8. AxellOnline
    Member

    I attempted with the pre submission hook and it did not work either. Any ideas?

    Posted 14 years ago on Thursday November 11, 2010 | Permalink
  9. Michael
    Member

    First of all a big thank you to the members of this forum for supplying a large number of code snippets; As I am not a PHP programmer I spent time browsing this forum to get the right PHP constructs for merging with elements of the wp-affilate code to create the following solution.

    a) The GF lead capture form needs the following three fields in place:
    e-mail address for the lead
    hidden field to capture client IP (default value)
    hidden field to capture unique id capable of being dynamically populated (I called mine unique_id)

    b) Shortcut to invoke form and pass unique id (in case you want to call form from multiple places on your website)
    [gravityform id=12 title=false description=false field_values='unique_id=1']

    c) Following code to go into functions.php - replace form id with your own form reference number and replace the field numbers for the three $_POST's.

    // November 2010 MJB - Add For Gravity Forms Post Submission
    function gf_post_submission($entry, $form){
        // Only Execute For Form 12 - Lead Capture
        if($form['id'] != 12) return $form;
        //Check For Presence Of Cookie ap_id
            $aff_id = $_COOKIE['ap_id'];
            if(!empty($aff_id))
            {
    // Build Lead Table Entries
    	    $reference   = $_POST["input_14"]; //Unique ID
                $clientdate  = (date ("Y-m-d"));
                $clienttime  = (date ("H:i:s"));
                $buyer_email = $_POST["input_3"];  //Email
                $ipaddress   = $_POST["input_12"]; // Client IP Address
                global $wpdb;
                $affiliates_leads_table_name = $wpdb->prefix . "affiliates_leads_tbl";
                $updatedb = "INSERT INTO $affiliates_leads_table_name (buyer_email,refid,reference,date,time,ipaddress) VALUES ('$buyer_email','$aff_id','$reference','$clientdate','$clienttime','$ipaddress')";
                $results = $wpdb->query($updatedb);
            }
    }
    add_action("gform_post_submission", "gf_post_submission", 10, 2);
    // End Addition For Gravity Forms

    Tested this morning and works for me...adding entries into the GF form and wp-affiliates Lead Gen tables.

    Michael.

    Posted 14 years ago on Tuesday November 16, 2010 | Permalink
  10. AxellOnline
    Member

    Michael
    You are the man! thanks for the solution!!!!!!

    i am having some trouble with the ip address coming in but in the grand scheme of things that isn't that big of an issue.

    Thank you so much

    Posted 14 years ago on Thursday November 18, 2010 | Permalink
  11. Scott
    Member

    How do you configure this code to work for multiple forms? For example, we have three forms setup on the website and we want to track the referrals for each.

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  12. You target a specific form in the filter call:

    add_action("gform_post_submission", "gf_post_submission", 10, 2);

    In this call it is using gform_post_submission and if you do that it will be globally applied to all forms.

    If you want to target a specific form you would do:

    add_action("gform_post_submission_5", "gf_post_submission", 10, 2);

    Notice the _5 on the end of gform_post_submission, that would target form id 5 and only form id 5.

    However in the example above the code that gets executed is gf_post_submission so you would have to do a different function call for each form.

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  13. Scott
    Member

    Thank you for your reply. I am a newbie here struggling through this. Here is the code base I am using.

    CODE BEGIN
    // November 2010 MJB - Add For Gravity Forms Post Submission
    function gf_post_submission($entry, $form){
    // Only Execute For Form 12 - Lead Capture
    if($form['id'] != 12) return $form;
    //Check For Presence Of Cookie ap_id
    $aff_id = $_COOKIE['ap_id'];
    if(!empty($aff_id))
    {
    // Build Lead Table Entries
    $reference = $_POST["input_14"]; //Unique ID
    $clientdate = (date ("Y-m-d"));
    $clienttime = (date ("H:i:s"));
    $buyer_email = $_POST["input_3"]; //Email
    $ipaddress = $_POST["input_12"]; // Client IP Address
    global $wpdb;
    $affiliates_leads_table_name = $wpdb->prefix . "affiliates_leads_tbl";
    $updatedb = "INSERT INTO $affiliates_leads_table_name (buyer_email,refid,reference,date,time,ipaddress) VALUES ('$buyer_email','$aff_id','$reference','$clientdate','$clienttime','$ipaddress')";
    $results = $wpdb->query($updatedb);
    }
    }
    add_action("gform_post_submission", "gf_post_submission", 10, 2);
    // End Addition For Gravity Forms

    I have three forms that I want to track:
    gravityform id=7
    gravityform id=6
    gravityform id=2

    Each form has different fields. When I made some changes to what I THOUGHT I should do, it didn't work and the site returned a blank page. I would GREATLY appreciate it if you could help me.

    Also, I you could spare some of your knowledge, in the instructions located here - http://www.tipsandtricks-hq.com/wordpress-affiliate/gravity-forms-and-wp-affiliate-platform-integration-385, I don't understand where the UNIQUE_ID comes into play.

    Thank you so much for your help!!!

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  14. @Scott You would have to contact the WP Affiliate Platform Plugin people are far as this custom code goes or the site where you got it from. We didn't write it, so it's not code we are familiar with as far as support goes.

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  15. sunstardave
    Member

    Thanks for putting these instructions up.

    I wasn't sure whether or not to start another topic or piggy back on this one so I hope the later is OK.

    Although I understand what is generally needed, I am lost on a few points:

    By the way, I’m using caps for clarity. I’m not shouting. :o )

    STEP 1)
    * e-mail address for the lead ~ NO PROBLEM
    * hidden field to capture client IP (default value) ~ NO PROBLEM
    * hidden field to capture unique id capable of being dynamically populated (I called mine unique_id) ~ THE HIDDEN FIELD HAS AN ADVANCED TAB WHICH DISPLAYS:

    A section: “Default Value” (dropdown) with “Insert Variable” as the default which has a blank field by default under it. WHICH VALUE IS SELECTED WHAT GOES IN THE FIELD?

    A section: “Allow field to be populated dynamically” (checkbox) and when checked, which is what we want, the following appears:

    A section: “Parameter Name:” with a blank field. WHAT GOES IN THIS FIELD?

    STEP 2)
    Shortcut to invoke form and pass unique id (in case you want to call form from multiple places on your website)

    [gravityform id=12 title=false description=false field_values='unique_id=1']
    I’M AFRAID I DON’T UNDERSTAND THIS AT ALL. WHAT DO I NEED TO CREATE/EDIT/ADD AND WHERE?

    STEP 3)
    Following code to go into “functions.php” file of your theme (NO PROBLEM) – replace form id with your own form reference number (I ASSUME THIS IS JUST THE FORM ID AND NOT SOME DIFFERENT REFERENCE NUMBER FOUND OR CREATED ELSEWHERE) and replace the field numbers for the three $_POST’s (WHAT ARE THEY REPLACED WITH?).

    I would be really grateful for any advice.

    Thanks,
    David

    Posted 13 years ago on Thursday March 31, 2011 | Permalink
  16. @sunstardave The "Default Value" area isn't for dynamically populating with custom code. It's purely for either a static Default Value *OR* using the Insert Form Field drop down that inserts a form field variable. It isn't used for populating a field using PHP or the query string. The only values that go in the Default Value is one you manually type in OR a variable from the Insert Form Field drop down that appears with that field.

    As for populating a field dynamically... the parameter field is up to you. What goes in the parameter field is the parameter you want to use to dynamically populate that field. You decide that. The parameter name is then used to target that field either with PHP using the gform_field_value hook OR via the query string by passing the value to the page containing the form (ex. mydomain.com/mypage?parameter=value). The parameter in the querystring would be whatever you chose, so if you set the parameter for an email field to "email" then you could pass data to it via PHP or the query strin g(ex. mydomain.com/mypage?email=email@email.com). Documentation for the gform_field_value hook is here:

    http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name

    Step 2: Again, you would pass the parameter names for the field you want to populate this way. The parameter names are whatever you configured for each field. For example if you gave an email field the parameter name of email you would pre-populate it like so:
    [gravityform id=12 title=false description=false field_values='email=email@email.com']

    So for example. If I edited an email field on my form, selected the Advanced tab and checked the "Allow field to be populated dynamically" tab and then gave it a parameter name of "email" (without the quotes) like so: http://grab.by/9LWP

    I could then populate that field dynamically via PHP using the gform_field_value hook, or via the query string by passing it (ex. mydomain.com/mypage?email=email@email.com) or via the shortcode ([gravityform id=12 title=false description=false field_values='email=email@email.com']).

    Your Step 3, yes the code would go in functions.php and the form id would be the form id for the form you want to customize. The field numbers are the input id numbers for the fields which you can find by viewing source on your form and getting the input name which will look something like "input_2" or "input_3", etc. the number is the field id.

    Posted 13 years ago on Thursday March 31, 2011 | Permalink
  17. sunstardave
    Member

    Thanks very much for such a detailed breakdown. It really helped and everything is working great.

    Thanks again!!

    David

    Posted 13 years ago on Friday April 1, 2011 | Permalink
  18. Hi!

    I've read through this forum posting a few times and can't seem to find a place to start to dig in. I'm looking to use the Affiliate Platform plugin with Gravity Forms and the PayPal addon to track sales, can sunstardave or Michael possibly help me out...is there a *complete* version of the instructions somewhere so I can start hacking away at this to get this working on my forms?

    Gravity Forms is already heads above anything else out there for flexible integrations into a website, I just haven't been able to find an affiliate platform to bolt on, getting this working would be huge!

    Much thanks!

    -r

    Posted 12 years ago on Monday April 16, 2012 | Permalink

This topic has been resolved and has been closed to new replies.