Title: Hookin
Last modified: August 30, 2016

---

# Hookin

 *  [RuneMarket](https://wordpress.org/support/users/runemarket/)
 * (@runemarket)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/hookin/)
 * Well… I’m very basic at coding but what I am trying to achieve is when the user
   purchases a subscription it updates there user role to contributor.
 * Then when the subscribtion runs out when the after they canceled to update it
   back to subscriber?
 * I’ve got this so far but am not having any luck.
 * add_action(‘paypal_ipn_for_wordpress_txn_type_recurring_payment’, ‘process_recurring_payment’,
   10, 1);
 * function process_recurring_payment( $posted )
    { // Parse data from IPN $posted[]
   array $mc_gross = isset($posted[‘mc_gross’]) ? $posted[‘mc_gross’] : ”; $protection_eligibility
   = isset($posted[‘protection_eligibility’]) ? $posted[‘protection_eligibility’]:”;
   $address_status = isset($posted[‘address_status’]) ? $posted[‘address_status’]:”;
   $item_number1 = isset($posted[‘item_number1’]) ? $posted[‘item_number1’] : ”;
   $payer_id = isset($posted[‘payer_id’]) ? $posted[‘payer_id’] : ”; $tax = isset(
   $posted[‘tax’]) ? $posted[‘tax’] : ”; $address_street = isset($posted[‘address_street’])?
   $posted[‘address_street’] : ”; $payment_date = isset($posted[‘payment_date’])?
   $posted[‘payment_date’] : ”; $payment_status = isset($posted[‘payment_status’])?
   $posted[‘payment_status’] : ”; $charset = isset($posted[‘charset’]) ? $posted[‘
   charset’] : ”; $address_zip = isset($posted[‘address_zip’]) ? $posted[‘address_zip’]:”;
   $mc_shipping = isset($posted[‘mc_shipping’]) ? $posted[‘mc_shipping’] : ”; $mc_handling
   = isset($posted[‘mc_handling’]) ? $posted[‘mc_handling’] : ”; $first_name = isset(
   $posted[‘first_name’]) ? $posted[‘first_name’] : ”; $mc_fee = isset($posted[‘
   mc_fee’]) ? $posted[‘mc_fee’] : ”; $address_country_code = isset($posted[‘address_country_code’])?
   $posted[‘address_country_code’] : ”; $address_name = isset($posted[‘address_name’])?
   $posted[‘address_name’] : ”; $notify_version = isset($posted[‘notify_version’])?
   $posted[‘notify_version’] : ”; $payer_status = isset($posted[‘payer_status’])?
   $posted[‘payer_status’] : ”; $business = isset($posted[‘business’]) ? $posted[‘
   business’] : ”; $address_country = isset($posted[‘address_country’]) ? $posted[‘
   address_country’] : ”; $num_cart_items = isset($posted[‘num_cart_items’]) ? $
   posted[‘num_cart_items’] : ”; $mc_handling1 = isset($posted[‘mc_handling1’]) ?
   $posted[‘mc_handling1’] : ”; $address_city = isset($posted[‘address_city’]) ?
   $posted[‘address_city’] : ”; $verify_sign = isset($posted[‘verify_sign’]) ? $
   posted[‘verify_sign’] : ”; $payer_email = isset($posted[‘payer_email’]) ? $posted[‘
   payer_email’] : ”; $mc_shipping1 = isset($posted[‘mc_shipping1’]) ? $posted[‘
   mc_shipping1’] : ”; $tax1 = isset($posted[‘tax1’]) ? $posted[‘tax1’] : ”; $txn_id
   = isset($posted[‘txn_id’]) ? $posted[‘txn_id’] : ”; $payment_type = isset($posted[‘
   payment_type’]) ? $posted[‘payment_type’] : ”; $last_name = isset($posted[‘last_name’])?
   $posted[‘last_name’] : ”; $address_state = isset($posted[‘address_state’]) ? 
   $posted[‘address_state’] : ”; $item_name1 = isset($posted[‘item_name1’]) ? $posted[‘
   item_name1’] : ”; $receiver_email = isset($posted[‘receiver_email’]) ? $posted[‘
   receiver_email’] : ”; $payment_fee = isset($posted[‘payment_fee’]) ? $posted[‘
   payment_fee’] : ”; $quantity1 = isset($posted[‘quantity1’]) ? $posted[‘quantity1’]:”;
   $receiver_id = isset($posted[‘receiver_id’]) ? $posted[‘receiver_id’] : ”; $txn_type
   = isset($posted[‘txn_type’]) ? $posted[‘txn_type’] : ”; $mc_gross_1 = isset($
   posted[‘mc_gross_1’]) ? $posted[‘mc_gross_1’] : ”; $mc_currency = isset($posted[‘
   mc_currency’]) ? $posted[‘mc_currency’] : ”; $residence_country = isset($posted[‘
   residence_country’]) ? $posted[‘residence_country’] : ”; $test_ipn = isset($posted[‘
   test_ipn’]) ? $posted[‘test_ipn’] : ”; $receipt_id = isset($posted[‘receipt_id’])?
   $posted[‘receipt_id’] : ”; $payment_gross = isset($posted[‘payment_gross’]) ?
   $posted[‘payment_gross’] : ”; $ipn_track_id = isset($posted[‘ipn_track_id’]) ?
   $posted[‘ipn_track_id’] : ”; $IPN_status = isset($posted[‘IPN_status’]) ? $posted[‘
   IPN_status’] : ”; $cart_items = isset($posted[‘cart_items’]) ? $posted[‘cart_items’]:”;
 *  /**
    * At this point you can use the data to generate email notifications, *
   update your local database, hit 3rd party web services, or anything * else you
   might want to automate based on this type of IPN. */ switch_to_blog($blogid);
   $user = new WP_User($user_id); $user->remove_role(‘subscriber’); $user->add_role(‘
   contributor’); restore_current_blog(); }
 * [https://wordpress.org/plugins/paypal-ipn/](https://wordpress.org/plugins/paypal-ipn/)

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/hookin/#post-6788769)
 * I think maybe you should be using [update_user_meta()](https://codex.wordpress.org/Function_Reference/wp_update_user)
   instead of what you’re doing. Have you tried that?

Viewing 1 replies (of 1 total)

The topic ‘Hookin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paypal-ipn_b2a7a0.svg)
 * [PayPal IPN for WordPress](https://wordpress.org/plugins/paypal-ipn/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paypal-ipn/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paypal-ipn/)
 * [Active Topics](https://wordpress.org/support/plugin/paypal-ipn/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paypal-ipn/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paypal-ipn/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [angelleye](https://wordpress.org/support/users/angelleye/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/hookin/#post-6788769)
 * Status: not resolved