latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

About: Don Pezet

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To

Viewing 6 topics - 1 through 6 (of 6 total)
Topic Count Last Reply
Issues with s2member_paid_registration_time()

By:  Don Pezet in: Community Forum

voices: 2
replies: 7

3 years, 4 months ago  Cristián Lávaque

Struggling with commissions

By:  Don Pezet in: Community Forum

voices: 1
replies: 2

3 years, 4 months ago  Don Pezet

Wrapping multiple shortcodes does not work

By:  Don Pezet in: Community Forum

voices: 5
replies: 13

3 years, 5 months ago  Julkie

Choosing the Right Affiliate Notification

By:  Don Pezet in: Community Forum

voices: 2
replies: 1

3 years, 5 months ago  Bruce

iDevAffiliate error with trial period

By:  Don Pezet in: Community Forum

voices: 2
replies: 4

3 years, 5 months ago  Bruce

Forums

By:  Don Pezet in: Community Forum

voices: 2
replies: 1

3 years, 6 months ago  Bruce

Viewing 6 topics - 1 through 6 (of 6 total)

My Latest Replies (From Various Topics)

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Thursday Aug 29th, 2013 at 9:29 am #58852
Don Pezet
Username: dpezet

OK, we are definitely getting closer. Using the switch_to_blog() function was definitely a missing piece in my solution, and I am now able to get values. However, s2member_paid_registration_time() is still not behaving as explained in the API. Here is my current example:

I have a PHP page coded as follows:

<html>
<body>
<?php
include "../wp-load.php";
switch_to_blog(4);
$user_id = (integer)$_GET['user_id'];
$blog_id = (integer)$_GET['blog_id'];
$user = new WP_User($user_id);
echo '$user_id : ' . $user_id . '<br>';
echo 's2member_registration_time($user_id): ' . s2member_registration_time($user_id) . '<br>';
echo 'Paid Registration Times from MySQL: ';
$s2member_paid_registration_times = get_user_option('s2member_paid_registration_times', $user_id);
print_r($s2member_paid_registration_times);
echo '<br>';
echo 's2member_paid_registration_time(): ' . s2member_paid_registration_time() . '<br>';
echo 's2member_paid_registration_time(\'level\',$user_id): ' . s2member_paid_registration_time('level',$user_id) . '<br>';
echo 's2member_paid_registration_time(\'level1\',$user_id): ' . s2member_paid_registration_time('level1',$user_id) . '<br>';
echo 's2member_paid_registration_time(\'level2\',$user_id): ' . s2member_paid_registration_time('level2',$user_id) . '<br>';
echo 's2member_paid_registration_time(\'level3\',$user_id): ' . s2member_paid_registration_time('level3',$user_id) . '<br>';
echo 's2member_paid_registration_time(\'level4\',$user_id): ' . s2member_paid_registration_time('level4',$user_id) . '<br>';
?>
</body>
</html>

I call it from a web browser via the following URL:

http://edutainmentlive.com/dpcustom/cancelation.php?user_id=18&subscr_id=18103761&blog_id=4

The page returns the folllowing:

$user_id : 18
s2member_registration_time($user_id): 1377574405
Paid Registration Times from MySQL: Array ( [level] => 1377574406 [level2] => 1377574406 ) 
s2member_paid_registration_time(): 0
s2member_paid_registration_time('level',$user_id): 1377574406
s2member_paid_registration_time('level1',$user_id): 1377574406
s2member_paid_registration_time('level2',$user_id): 1377574406
s2member_paid_registration_time('level3',$user_id): 1377574406
s2member_paid_registration_time('level4',$user_id): 1377574406

This user has only purchased one membership in their lifetime and it was a level 2 membership. The array reflects that as expected. However, the output from s2member_paid_registration_time() reflects something different. It shows that level 1, 3 and 4 memberships were also purchased. It also shows a 0 value when querying for the “first” paid membership (which is the value I want to use in the hook I am writing). The API documentation says that it should behave as follows:

<?php
$time = s2member_registration_time (); # first registration time (free or otherwise).
$time = s2member_paid_registration_time (); # first "paid" registration and/or upgrade time.
$time = s2member_paid_registration_time ("level1"); # first "paid" registration or upgrade time at Level#1.
$time = s2member_paid_registration_time ("level2"); # first "paid" registration or upgrade time at Level#2.
$time = s2member_paid_registration_time ("level3"); # first "paid" registration or upgrade time at Level#3.
$time = s2member_paid_registration_time ("level4"); # first "paid" registration or upgrade time at Level#4.
?>

So if I am reading that correctly, instead of what I got above, my page should be returning this:

$user_id : 18
s2member_registration_time($user_id): 1377574405
Paid Registration Times from MySQL: Array ( [level] => 1377574406 [level2] => 1377574406 ) 
s2member_paid_registration_time(): 1377574406
s2member_paid_registration_time('level',$user_id): 1377574406
s2member_paid_registration_time('level1',$user_id): 0
s2member_paid_registration_time('level2',$user_id): 1377574406
s2member_paid_registration_time('level3',$user_id): 0
s2member_paid_registration_time('level4',$user_id): 0

Do you or Jason have any ideas as to why I am getting the errant results? I’m not too concerned about the individual levels, but my primary goal is that I need a way to query how long it has been since a user paid for their first subscription, regardless of what level it was. Calling s2member_paid_registration_time() without any arguments is supposed to return that, but I am getting 0. Calling s2member_paid_registration_time(‘level’,$user_id) seems to return the value I want, but it is undocumented in the API and I want to make sure I am writing code that will survive future updates.

Thanks again,

Don

Posted: Wednesday Aug 28th, 2013 at 2:38 pm #58815
Don Pezet
Username: dpezet

It occurred to me that the function may not be mutlisite aware. I am running WordPress 3.6 Multisite. My root site does not allow user registration. So, the user in my example is a paid member of one of my subsites. Their paid registration time is stored in “wp_4_s2member_paid_registration_times” in MySQL as that particular subsite is site #4. I would bet that the s2member_paid_registration_time() is querying “wp_s2member_paid_registration_times” instead which is not going to return anything, thus the zeros. Is there a way to tell s2Member which site number it should be working with? The codex doesn’t seem to show anything.

Thanks,

Don

Posted: Wednesday Aug 28th, 2013 at 2:00 pm #58813
Don Pezet
Username: dpezet

Is there any chance I could get some help with this? It appears to be a bug in s2member_paid_registration_time() as the function is not behaving as described in the s2Member Codex.

Posted: Thursday Aug 22nd, 2013 at 9:35 pm #56489
Don Pezet
Username: dpezet

I think I figured this out. Does s2member_paid_registration_time() return a paid timestamp if the user is still in a free trial period? My guess is no, which is what was causing my issue. We don’t have free registrations on our site, so I just switched over to s2member_registration_time() and it worked like a champ. In case anyone finds this thread later on down the road, here is my working file for canceling the commission if the account is canceled while it is still in the trial period (7 days for my site):

<html>
<body>
<?php
include "../wp-load.php";
$user_id = (integer)$_GET['user_id'];
$subscr_id = (integer)$_GET['subscr_id'];
$user = new WP_User($user_id);
if(s2member_registration_time($user_id) < strtotime('8 days'))
  {
    $url = 'http://www.idevaffiliate.com/12345/API/scripts/terminate_commission.php?secret=12345678&order_number=' . $subscr_id;
    @file_get_contents( $url );
    exit;
  }
exit;
?>
</body>
</html>

Now that I have it working this way, I need to see if I can rewrite it as a notification hook instead so I am not dependent on PHP calls outside of WordPress. At least I know it does work.

Don

Posted: Thursday Aug 22nd, 2013 at 5:40 pm #56467
Don Pezet
Username: dpezet

OK, here’s my latest stab at this one. First, I created an API/Signup Notification as follows:

http://www.idevaffiliate.com/12345/sale.php?idev_commission=%%cv1%%&idev_ordernum=%%subscr_id%%&affiliate_id=%%coupon_affiliate_id%%&ip_address=%%user_ip%%

Next, I created an API/Cancellation Notification as follows:

http://edutainmentlive.com/dpcustom/cancel-commission.php?subscr_id=%%subscr_id%%&user_id=%%user_id%%

Lastly, I created cancel-commission.php as follows:

<html>
<body>
<?php
include "../wp-load.php";
if(!empty($_GET['subscr_id']) && !empty($_GET['user_id']))
  {
    $user_id = (integer)$_GET['user_id'];
    $subscr_id = (integer)$_GET['subscr_id'];
    $user = new WP_User($user_id);
//    $s2member_paid_registration_times = get_user_option('s2member_paid_registration_times', $user_id);
    if(s2member_paid_registration_time('level',$user_id) < strtotime('8 days'))
      {
	    $url = 'http://www.idevaffiliate.com/12345/API/scripts/terminate_commission.php?secret=1234512345&order_number=' . $subscr_id;
	    @file_get_contents( $url );
      }
  }
  exit;
}
?>
</body>
</html>

I figured this would knock it out of the park. Commissions are only issued for initial payments. Then, if someone cancels during their 7 day trial, revoke the commission. If they are beyond their 7 day trial, let the commission stand. Unfortunately, it doesn’t work. It looks like s2member_paid_registration_time() is not returning a value when used this way. Can you spot what is wrong with my code?

Thanks,

Don

  • This reply was modified 3 years, 4 months ago by  Don Pezet.
Posted: Friday Aug 2nd, 2013 at 9:40 am #54770
Don Pezet
Username: dpezet

I can confirm that it does work for me now. You can flag my issue as resolved.

Thanks for resolving this in such a short amount of time even though it wasn’t a critical issue. You guys must never sleep.

Don

Posted: Thursday Aug 1st, 2013 at 9:41 pm #54700
Don Pezet
Username: dpezet

OK, so something is strange on my end then. I have updated to the latest version and when I attempt to wrap up more than one pro-form I still receive this error:

Invalid form configuration. Missing “desc” attribute. Please provide a Description for this form.

I even tried the cutting and pasting the exact code from the documentation and received the same error. This is the example I used:

[s2Member-Pro-AuthNet-Form rp="1" rt="M" rr="1" accept_coupons="1"]
	[s2Member-Pro-AuthNet-Form level="1" desc="Option 1 ($10.00)" ra="10.00" /]
	[s2Member-Pro-AuthNet-Form level="2" desc="Option 2 ($20.00)" ra="20.00" /]
	[s2Member-Pro-AuthNet-Form level="3" desc="Option 3 ($30.00)" ra="30.00" /]
[/s2Member-Pro-AuthNet-Form]

I placed that on a page all by itself with no other content and received the above error. You can see it for yourself here:

Posted: Thursday Aug 1st, 2013 at 6:25 pm #54666
Don Pezet
Username: dpezet

I made the change. The duplicate form error is now gone, but the page is still not working. It now throws this error:

Invalid form configuration. Missing “desc” attribute. Please provide a Description for this form.

Even though I specifically have a description listed for each form (see my code above).

Posted: Thursday Jul 25th, 2013 at 10:08 pm #54115
Don Pezet
Username: dpezet

Bruce,

Ah, I spotted the issue. I am using API/Tracking and I used %%initial%% for the sale amount instead of %%regular%% which is why I was getting the $0 sale. That was specifically called out in the configuration video, but apparently I wasn’t paying attention.

Thank you for your help,

Don

Viewing 9 replies - 1 through 9 (of 9 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.