<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Hook requests for paypal plugin</title>
		<link>https://legacy.forums.gravityhelp.com/topic/hook-requests-for-paypal-plugin</link>
		<description>Gravity Support Forums Topic: Hook requests for paypal plugin</description>
		<language>en-US</language>
		<pubDate>Wed, 08 Apr 2026 12:47:55 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/hook-requests-for-paypal-plugin" rel="self" type="application/rss+xml" />

		<item>
			<title>jloosli on "Hook requests for paypal plugin"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/hook-requests-for-paypal-plugin#post-20453</link>
			<pubDate>Sat, 12 Mar 2011 14:22:14 +0000</pubDate>
			<dc:creator>jloosli</dc:creator>
			<guid isPermaLink="false">20453@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am putting together a site that has various subscriptions and products that open up capabilities in wordpress. I'm using the user access manager plugin to manage the access a user would have to his or her subscribed to or purchased products. I have to do it this way instead of by role since a single user might have multiple subscriptions at any given time.&#60;br /&#62;
&#60;a href=&#34;http://wordpress.org/extend/plugins/user-access-manager/&#34; rel=&#34;nofollow&#34;&#62;http://wordpress.org/extend/plugins/user-access-manager/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The way I have things set up is that I have created a plugin to which I can match a given form to a user access group. Then, I have tied into the gform_paypal_post_ipn hook to see when someone subscribes and the gform_subscription_canceled hook to determine when someone unsubscribes. Then I go find the form tied to the subscription event, find the connection to the User Access Manager group, and enable or disable it.&#60;/p&#62;
&#60;p&#62;As you can see below, the gform_subscription_canceled hook is a little easier to work with. So my request is to put in hooks for &#60;u&#62;all the paypal transaction id's&#60;/u&#62;, for example subscr_signup, and {I'm forgetting the other ones right now]. That would make it much easier to grab what is going on.&#60;/p&#62;
&#60;p&#62;gform_paypal_post_ipn calls:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;function paypal_hook($post, $entry, $config, $cancel)
        {
            global $wpdb;
            $post= (object) $post;
            if(&#38;quot;subscr_signup&#38;quot; == $post-&#38;gt;txn_type) {
                $custom=explode(&#38;quot;&#124;&#38;quot;,$post-&#38;gt;custom);     // Custom is in the form of {Lead ID}&#124;{some other stuff}
                $lead=$custom[0];                       // I want the lead ID

                //get the form associated with the lead
                $sql=$wpdb-&#38;gt;prepare(&#38;quot;SELECT form_id FROM {$wpdb-&#38;gt;prefix}rg_lead WHERE id=%d&#38;quot;,$lead);
                $form=$wpdb-&#38;gt;get_var($sql);

                // Get user ID
                $sql=$wpdb-&#38;gt;prepare(&#38;quot;SELECT created_by FROM {$wpdb-&#38;gt;prefix}rg_lead WHERE id=%d;&#38;quot;,$lead);
                $user=$wpdb-&#38;gt;get_var($sql);
                if(is_null($user)) {
                    $subject=&#38;quot;Couldn&#38;#39;t Find user to add to subscription&#38;quot;;
                    $msg=&#38;quot;Variables:\n\n&#38;quot;.var_export(get_defined_vars(),TRUE);
                    mail($this-&#38;gt;debugmail,$subject,$msg);
                    return;
                }

                $connections = get_option(&#38;quot;gf_uam_settings&#38;quot;);   // Gets settings in the form of $a[form_id]=access ID
                if(isset($connections[$form])) {
                    $this-&#38;gt;addCapability($user,$connections[$form]);
                } else {
                    $subject=&#38;quot;Trying to subscribe but form not connected to capability&#38;quot;;
                    $msg=&#38;quot;Variables:\n\n&#38;quot;.var_export(get_defined_vars(),TRUE);
                    mail($this-&#38;gt;debugmail,$subject,$msg);
                }
            } else {
                $subject=&#38;quot;Non subscription IPN&#38;quot;;
                $msg=&#38;quot;Variables:\n\n&#38;quot;.var_export(get_defined_vars(),TRUE);
                mail($this-&#38;gt;debugmail,$subject,$msg);

            }
        }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and for gform_subscription_canceled hook:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;function cancel_hook($entry, $config, $tr_id)
        {
            $user=$entry[&#38;#39;created_by&#38;#39;];
            $form=$entry[&#38;#39;form_id&#38;#39;];
            $connections = get_option(&#38;quot;gf_uam_settings&#38;quot;);   // Gets settings in the form of $a[form_id]=access ID
            if(isset($connections[$form])) {
                $this-&#38;gt;removeCapability($user,$connections[$form]);
            } else {
                $subject=&#38;quot;Couldn&#38;#39;t find form connection to cancel subscription&#38;quot;;
                $msg=&#38;quot;Variables:\n\n&#38;quot;.var_export(get_defined_vars(),TRUE);
                mail($this-&#38;gt;debugemail,$subject,$msg);
            }
            $subject=&#38;quot;At end of cancel hook&#38;quot;;
            $msg=&#38;quot;Variables:\n\n&#38;quot;.var_export(get_defined_vars(),TRUE);
            mail($this-&#38;gt;debugemail,$subject,$msg);

        }&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
