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™

EOT / Delete Notifications not working?

s2Member Plugin. A Membership plugin for WordPress®.

EOT / Delete Notifications not working?

Postby mycodetree » July 30th, 2010, 1:12 pm

I can get every other conditional notification to work but the EOT / Delete. I've tried manually deleting the user from admin and it says that it should trigger the notification urls for EOT ... but my testing has shown that it is not in my case. I've even tried to manually expire the user's EOT in the profile and then let the CRON job delete them ... it still doesn't trigger the EOT url notifications for me?

Any ideas?

Here are the specs on my s2member:

Version: 3.1.5
Stable tag: 3.1.5
Framework: WS-P-3.0

I'm using WP 3.0.1
User avatar
mycodetree
Registered User
Registered User
 
Posts: 11
Joined: July 30, 2010

Re: EOT / Delete Notifications not working?

Postby mycodetree » July 30th, 2010, 2:56 pm

I'm using this as a ticket thread to keep everyone updated as I work on this.

The 'sticky' area seems to be:

/includes/functions/user-deletions.inc.php

Specifaically, this chunk of code:
Code: Select all
            
if (is_object ($user = new WP_User ($user_id)) && $user->ID && $subscr_id && $custom && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))
               {
                  foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) /* Handle eot notifications on user deletion. */
                            if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace ("/%%subscr_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($subscr_id)), $url)))
                        if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->first_name)), $url)) && ($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->last_name)), $url)))
                           if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode (trim ($user->first_name . " " . $user->last_name))), $url)))
                              if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($user->user_email)), $url)))
                                 /**/
                                 if (($url = trim ($url))) /* Empty? */
                                    ws_plugin__s2member_remote ($url);
                  /**/
                  eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                  do_action ("ws_plugin__s2member_during_handle_user_deletions", get_defined_vars ());
                  unset ($__refs, $__v); /* Unset defined __refs, __v. */
               }

That is the conditional statement that determines if the EOT urls are notified with the ws_plugin_s2member_remote() function. You'll notice that at the end of the condition an 'empty' check is done ($url=trim($url)) and if it isn't true, nothing is notified.

Through debuging so far, I have found that the $url var is empty (not null) by the time it gets to the $url=trim($url) comparison.

Off the top, this looks like it might be a reg ex issue, I need to do some additional backtrace at dump the $url var at all stages though.
User avatar
mycodetree
Registered User
Registered User
 
Posts: 11
Joined: July 30, 2010

Re: EOT / Delete Notifications not working?

Postby mycodetree » July 30th, 2010, 3:33 pm

The issue is here at the beginning of the condition:

Code: Select all
if (is_object ($user = new WP_User ($user_id)) && $user->ID && $subscr_id && $custom && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array ($cv = preg_split ("/\|/", $custom)))


If !$subscr_id or !$custom, the condition will never fire (and the eot notification urls will never be pinged).

Now this may seem unintuitive but in my opinion, the EOT/Deletion notifications should still fire EVEN IF the user doesn't have a paypal subscriber ID. I know, you're saying but why would they be a user if they never made it through the paypal process? I can think of a hundred reasons to have WP users that aren't 'paid members'.

Beyond that though, s2member docs say that it will ping the EOT/Delete notification URLS even in the case of a manual delete from the Dashboard. To me, that indicates any user that I choose to delete via WP Admin. What the docs don't mention is that the user has to have been a 'paid member' and have gone through the 'process' first.

I have a reason for EOT urls to be pinged when ANY user is deleted, not just ones that were originally paid members. I think s2member could change the documentation to explain this a little better OR (cross fingers) support the pinging of EOT URLS when ANY user is deleted :)

I love s2member but this little snafo cost me about 7.5 hours :|

To be clear, I don't think this is a bug ... I think s2member is behaving as it was designed, I just didn't find the design of this area particularly intuitive.
User avatar
mycodetree
Registered User
Registered User
 
Posts: 11
Joined: July 30, 2010

Re: EOT / Delete Notifications not working?

Postby mycodetree » July 30th, 2010, 4:23 pm

So I have a home-spun patch for anyone interested:

Open up ../includes/functions/user-deletions.inc.php

Locate this code:

Code: Select all
$custom = get_usermeta ($user_id, "s2member_custom");
$subscr_id = get_usermeta ($user_id, "s2member_subscr_id");


and replace it with this code:

Code: Select all
$custom = get_usermeta ($user_id, "s2member_custom");
if (empty($custom) OR $custom =='' OR is_null($custom)) { $custom = true; }
$subscr_id = get_usermeta ($user_id, "s2member_subscr_id");
if (empty($subscr_id) OR $subscr_id =='' OR is_null($subscr_id)) { $subscr_id = true; }


This change will allow EOT notifications to be sent out when a user is deleted with or without the custom or subscriber id. Alternatively, we could just remove the conditional checks from the 'IF' statement but when your dealing with 3rd party code it's best to add your own code that you can remove later rather than start removing their code.

All this change is doing is making sure that the $subscr_id and $custom variables are true IF they do not currently have a value (otherwise they would be false and we'd be in the same spot we started).

I hope that s2member considers a more permanent solution in their next release whether it is to support non-member EOT/Delete notifications or to simply change the documentation a little bit.
User avatar
mycodetree
Registered User
Registered User
 
Posts: 11
Joined: July 30, 2010

Re: EOT / Delete Notifications not working?

Postby martonic » August 1st, 2010, 1:55 am

Very interesting. The code displayed above seems to fix a bug in these notifications.

How can we have members who have not paid through Paypal? One way, is if they paid by check! And this has to be supported, at least in the system I'm working on at the moment.

Thanks for a helpful insight and code snippet here! :mrgreen:
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: EOT / Delete Notifications not working?

Postby Jason Caldwell » August 5th, 2010, 3:13 pm

Thanks for the time you spent on this. Much appreciated.
I have a reason for EOT urls to be pinged when ANY user is deleted, not just ones that were originally paid members. I think s2member could change the documentation to explain this a little better OR (cross fingers) support the pinging of EOT URLS when ANY user is deleted :)

I love s2member but this little snafo cost me about 7.5 hours :|

To be clear, I don't think this is a bug ... I think s2member is behaving as it was designed, I just didn't find the design of this area particularly intuitive.

Just wanted to let you know that I saw this.
I'll consider a change in a future release. Possibly an option that controls this behavior. Originally, this was designed to prevent a notification to an outside script that would *assume* it was for a paid Customer, and possibly cause further confusion; but I can see now that having this as an option would make s2Member even more powerful in this regard - under certain circumstances.
~ 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: EOT / Delete Notifications not working?

Postby martonic » August 10th, 2010, 12:08 pm

For me, the absence of notifications is a problem that should be corrected. If an account has an s2member role and is now getting demoted (or deleted) that is an important event. What difference does it make how that role got acquired?

This problem exists both here:

user-deletions.inc.php

and here:

auto-eots.inc.php

:arrow: So if anyone wants to "hack" it fixed, you need to hack both of the above files.
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: EOT / Delete Notifications not working?

Postby Jason Caldwell » August 17th, 2010, 2:21 pm

Update on this topic. ~ Thanks everyone.
This issue was addressed in the release of s2Member v3.2

@COMPLETED/TODO

- API Behavior. s2Member's API Notification for EOT/Deletions, has been changed slightly. In previous versions, the EOT/Deletion notification was only processed for a ( paid ) Member, who reached the end of their term, OR ... if a ( paid ) Member was manually deleted by an Administrator through the Dashboard. Starting with s2Member v3.2+, an EOT/Deletion Notification will be processed, EVEN if the account is NOT currently associated with a ( paid ) Member. In other words, starting with s2Member v3.2, if you delete an account manually ( through your WP Dashboard ) this will ALWAYS trigger s2Member's EOT/Deletion Notification; no matter what. For further details, check your Dashboard: `s2Member -> API Notifications -> EOT/Deletion`.
~ 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: EOT / Delete Notifications not working?

Postby martonic » August 18th, 2010, 12:11 pm

Hi again Jason,

What about an EOT - will a notification now be sent when demotion occurs In all cases - even when there is no subscriber-id? :?:
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: EOT / Delete Notifications not working?

Postby Jason Caldwell » August 24th, 2010, 12:27 pm

martonic wrote:Hi again Jason,

What about an EOT - will a notification now be sent when demotion occurs In all cases - even when there is no subscriber-id? :?:

Yes, that is correct. s2Member's Auto-EOT system also follows this same logic. This new rule applies to ALL forms of EOT/Deletions; including even when the Auto-EOT System is handling things, and there is no payment associated.

* I confirmed this against the latest release of s2Member v3.2.2.
However, I'm pretty sure this has been the case since 3.2.0 though.
~ 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: EOT / Delete Notifications not working?

Postby martonic » August 24th, 2010, 12:58 pm

Hi Jason,

I checked the code for version 3.2.2 in

auto-eots.inc.php

and it still seems to require that both "custom" and "subscr_id" must be set before sending a notification.

Is that not correct?

EDIT - I will have to test it.

Thanks, Marty
User avatar
martonic
Experienced User
Experienced User
 
Posts: 70
Joined: July 14, 2010

Re: EOT / Delete Notifications not working?

Postby Jason Caldwell » August 27th, 2010, 2:21 pm

Hi Marty. I can confirm that s2Member v3.2.2+ is no longer dependent
on those variables being present for an EOT to be processed.
This is the intended behavior.

~ As always, great to have your feedback.
Please report all bugs.
~ 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: Google [Bot] and 0 guests

cron