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.

CODE SNIPPETS?!

  1. net_mage
    Member

    GF staff,

    I love this plugin and it has made my life a lot easier however it is very frustrating that there are code snippets floating all over the forums and the documentation page is very bare. Is there any way you can make it a priority to organize your code snippets (which are extremely helpful to the non-programmers) in a wiki or on the documentation page? Otherwise its almost impossible for beginners to use all of the amazing options without examples. Thanks guys.

    For instance this code snippet relating to post form submission:

    add_action("gform_post_submission", "post_to_paypal", 10, 2);
    
    function post_to_paypal($entry, $form){
        if($form["id"] != 3) //NOTE: replace 3 with your form id
            return;
        ?>
            <form method="post" action="http://paypalURL" name="form_to_paypal" id="form_to_paypal">
                <input type="hidden" name="name" value="<?php echo $entry["1"] ?>" />
                <input type="hidden" name="email" value="<?php echo $entry["2"] ?>" />
                <input type="hidden" name="phone" value="<?php echo $entry["3"] ?>" />
                NOTE: $entry["1"] will return field with ID=1. You can view the field ID by inspecting that input's markup
                .... add your other fields here
    
            </form>
            <script type="text/javascript">
                document.getElementById("form_to_paypal").submit();
            </script>
        <?php
    }

    This could temporarily solve the PayPal dilemma a lot of people are having so long as they don't need ipn. Just my two cents.

    Oh this is the default paypal submission form. Just tailor the form above to include the values you need/want.

    <FORM ACTION="https://www.paypal.com/cgi-bin/webscr" METHOD="POST">
    <INPUT TYPE="hidden" NAME="cmd" VALUE="_xclick">
    <INPUT TYPE="hidden" NAME="business" VALUE="recipient@paypal.com">
    <INPUT TYPE="hidden" NAME="undefined_quantity" VALUE="1">
    <INPUT TYPE="hidden" NAME="item_name" VALUE="hat">
    <INPUT TYPE="hidden" NAME="item_number" VALUE="123">
    <INPUT TYPE="hidden" NAME="amount" VALUE="15.00">
    <INPUT TYPE="hidden" NAME="shipping" VALUE="1.00">
    <INPUT TYPE="hidden" NAME="shipping2" VALUE="0.50">
    <INPUT TYPE="hidden" NAME="currency_code" VALUE="USD">
    <INPUT TYPE="hidden" NAME="first_name" VALUE="John">
    <INPUT TYPE="hidden" NAME="last_name" VALUE="Doe">
    <INPUT TYPE="hidden" NAME="address1" VALUE="9 Elm Street">
    <INPUT TYPE="hidden" NAME="address2" VALUE="Apt 5">
    <INPUT TYPE="hidden" NAME="city" VALUE="Berwyn">
    <INPUT TYPE="hidden" NAME="state" VALUE="PA">
    <INPUT TYPE="hidden" NAME="zip" VALUE="19312">
    <INPUT TYPE="hidden" NAME="lc" VALUE="US">
    <INPUT TYPE="hidden" NAME="email" VALUE="buyer@domain.com">
    <INPUT TYPE="hidden" NAME="night_phone_a" VALUE="610">
    <INPUT TYPE="hidden" NAME="night_phone_b" VALUE="555">
    <INPUT TYPE="hidden" NAME="night_phone_c" VALUE="1234">
    <INPUT TYPE="image" NAME="submit" BORDER="0" SRC="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" ALT="PayPal - The safer, easier way to pay online">
    <img alt="" border="" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif">
    </FORM>

    All you paypal people out there. Enjoy.

    Posted 13 years ago on Tuesday May 4, 2010 | Permalink
  2. I agree. Better hook/API documentation is pretty high in our priority list. Hang in there! And thanks for the PayPal code snippet.

    Posted 13 years ago on Wednesday May 5, 2010 | Permalink
  3. Thanks for that snippet, it could come in very useful :o)

    If the admin here have their hands full with programming, I'd be happy to write something up. I admit that I am better known for writing horror, but I've written about 15 wp theme user guides in the past (proper ones for StyleWP last year, not those 3 page guides with a paragraph on each page).

    Posted 13 years ago on Wednesday May 5, 2010 | Permalink