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.

Update a post custom form & Paypal

  1. popsantiago
    Member

    Hello

    How can i update a custom field of custom post type after a paypal paiement using gravityform ?
    Do you have any idea or documentation ?

    Thank you,

    Pop

    Posted 11 years ago on Saturday January 12, 2013 | Permalink
  2. You can use the gform_paypal_fulfillment hook to run actions when a PayPal transaction is completed. http://www.gravityhelp.com/documentation/page/Gform_paypal_fulfillment

    You can write a function that updates a post and adds the information to the custom field. We'll need more information from you to be able to give you more specific assistance. The code will look something like this:

    [php]
    add_action("gform_paypal_fulfillment", "update_custom_field", 10, 4);
    function update_custom_field($entry, $config, $transaction_id, $amount) {
        $post_id = $entry['post_id'];
        // define your meta key name here
        $meta_key = 'custom_field_name';
        // write the transaction ID to the meta key
        update_post_meta($post_id, $meta_key, $transaction_id);
    }
    Posted 11 years ago on Sunday January 13, 2013 | Permalink
  3. popsantiago
    Member

    Hi Chris,

    I created a form to post an ads (CPT) on my website with GF, i used the paypal add-on to give the possibility to add the ad to featured ads (checkbox/product/paypal). This part is done.

    But maybe customer want to put on featured ads his content in second time. So that's why i would like to add the possibility to pay for that :
    => update meta_key = is_featured (7 days / 15days, etc.)

    Can you confirm me if i go to the right way plz ?
    If i want use your example of function, i need to create a new form (called by mysite.com/myformfeature/?post_id=XX) with paypal add-on with dynamic value for an hidden field that will be the post_id and that's done ? (after added your function in the paypal.php file)

    To display post i would like to query post with : is_featured / now() / date(SubmissionFeature).

    If i use your function example, what's date value will be update ? get_the_modified_date() or get_the_date( ).
    Or to do my calculation do you think it's easier to save the date of transaction in a hidden field ?

    I hope you will understand my bad english =/

    See you.

    Pop

    Posted 11 years ago on Sunday January 13, 2013 | Permalink
  4. Are you saying you want to update a post which already exists, after getting a PayPal payment, with the new expiration date or how long the post should stay visible? The post (ad) already exists, and you are giving the opportunity to run the ad longer, by making a PayPal payment?

    If that is true, I don't think it will be too difficult. You can pre-populate the form as you are doing with the query string link and the post_id in it. That will get you the post_id. Then, use the field value where that is stored to update the post meta:

    [php]
    $post_id = $entry['field_id_where_post_id_is_stored'];
    $expires = 'whatever your expiration date is';
    update_post_meta($post_id, ' is_featured', $expires);

    You will have to figure out how to calculate the expiration date, then use that in your custom post template to not show posts with expired dates in the meta key.

    Posted 11 years ago on Monday January 14, 2013 | Permalink
  5. popsantiago
    Member

    Hey Chris

    That's i need !

    Thank you,

    Pop

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  6. You're welcome. If you get stuck, let us know and we will try to help.

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink