PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Demoted member re-activate himself (request for new Hooks!)

s2Member Plugin. A Membership plugin for WordPress®.

Demoted member re-activate himself (request for new Hooks!)

Postby toddz88 » June 1st, 2011, 3:01 am

I want to enable members who were demoted - due to Failed Payments at Paypal - to re-activate themselves.

The s2m Billing Update Form allows a member to update the credit-card in his Paypal billing profile. But this alone does not actually:
1) re-activate his subscription profile at Paypal, nor
2) un-demote him on my site.

TO RE-ACTIVATE THE PROFILE AT PAYPAL
According to the Paypal Website Payments Pro API documentation pdf (pg68), we need to:
- first, use UpdateRecurringPaymentsProfile to increase the Maximum number of Failed Payments.
- then, use ManageRecurringPaymentsProfileStatus to change his paypal billing Status from Suspended to Active.

TO UN-DEMOTE THE MEMBER ON MY SITE
Then s2m needs to un-demote / revert his Role from "Suspended" (the name of my Level-0 / Demoted role), to the role he originally had on my site (either Individual or Group), to restore his access to my protected content.

Paypal does not send an IPN for status changes (see pdf pg71-72), so I can't use s2m api Notifications. Instead I need to make s2m do it based only on a success response from the final api call (ManageRecurringPaymentsProfileStatus), after the member submits the Billing Update form.

I actually was able to accomplish all this -- by directly editing an s2m file (s2member-pro/includes/classes/gateways/paypal/paypal-update-in.inc.php) -- but obviously "hacking" s2m is a bad idea, since i'll lose my changes on the next update. Unfortunately there are NO HOOKS there (yet?!) to use instead. Here's the idea, pretty simple really:
Code: Select all
# RE-ACTIVATE PAYPAL BILLING PROFILE
// place below on line 101, after ZIP. 
$paypal["MAXFAILEDPAYMENTS"] = 3;

// place below on line 111, after sending updated billing info to paypal.
$paypal = array (); /* Reset the PayPal® array. */
$paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
$paypal["PROFILEID"] = $cur__subscr_id;
$paypal["ACTION"] = "Reactivate";
$paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal); // ToDo: put back the if() and __error check .

#UNDEMOTE MEMBER IN SITE / S2M
//ToDo: get user's original Role (stored in s2m field 'custom' as 'cv1'), put in $orig_role;
$member_obj = new WP_User($user_id);
$member_obj->set_role($orig_role);

* NOTE -- This code is draft / proof-of-concept only; still needs error handling, another level of if() nesting, and a conditional to run it only if member is suspended and has not cancelled.

So.. I think this would basically work, and would be great functionality for my site, so I'd love to be able to use this approach. But without the necessary Hook(s), I shouldn't do it.
* JASON -- ANY CHANCE OF ADDING THESE HOOKS TO THE COMING RELEASE ? *


ALTERNATIVE APPROACH
Another approach to enabling a member to re-activate himself, is not fully-automatic. I think I can use a Success URL (Custom Return URLs on Success) in my ShortCode for the Billing Update Form, so a successful submission hits a url for a wp page that uses a custom template file, with the same php above to UnDemote the member, and then also send an email to the site owner to notify him to go into Paypal and MANUALLY Re-Activate the billing profile. Not an ideal situation, since it's not fully automated, but maybe better than hacking s2m files.
User avatar
toddz88
Experienced User
Experienced User
 
Posts: 61
Joined: November 19, 2010

Re: Demoted member re-activate himself (request for new Hook

Postby Jason Caldwell » June 3rd, 2011, 1:39 am

Thanks for this post. I'm reviewing it now.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Demoted member re-activate himself (request for new Hook

Postby Jason Caldwell » June 3rd, 2011, 9:37 pm

Gotchya. Yes, I can see where Hooks in this routine would be very helpful in cases such as this. If not in the very next release, in the releases that will follow shortly thereafter. I'm marking this thread. Thank you VERY much for the great suggestion.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Demoted member re-activate himself (request for new Hook

Postby Jason Caldwell » August 18th, 2011, 9:05 pm

Update. Starting with s2Member Pro v110710+, Shortcode attributes rrt and rra are now possible for Pro Form Shortcodes, allowing greater control over this aspect of s2Member's behavior. See: s2Member -> PayPal Pro Forms -> Shortcode Attributes.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests

cron