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.

conditional statement for recurring charge

Home Forums Community Forum conditional statement for recurring charge

This topic contains 5 replies, has 2 voices. Last updated by  Cristián Lávaque 4 years, 10 months ago.

Topic Author Topic
Posted: Friday Mar 9th, 2012 at 8:34 pm #7819
bigt11
Username: bigt11

I want to offer my members a path to upgrade via paypal buttons. I have different buttons to offer them the choice of a single payment for 1 month, no recurring, and another for per month subscription.

Im in need of some sort of conditional statement to place on my “modify your subscription” page so a monthly recurring subscriber can cancel the subscription, but a single payment non recurring subscriber cannot see it. I want to have all options on 1 page so conditional statements are a must.

Thanks,

P.S. Coming over from WPMU DEV membership plugin. You have already released more updates in a 2-3 day span than they did in a 3 month span, and your plugin actually works. Loving it so far.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Saturday Mar 10th, 2012 at 2:04 am #7825

Hi! Thanks for the kudos! :)

I think you can do the conditional checking if the subscr ID is empty or not. If not, then the user has a subscription going.
[hilite path]Dashboard -› s2Member® -› API / Scripting -› PHP/API Constants -> S2MEMBER_CURRENT_USER_SUBSCR_ID[/hilite]

Something like this maybe:

[hilite pre_code]
if (current_user_can('access_s2member_level1')
{
if (empty(S2MEMBER_CURRENT_USER_SUBSCR_ID))
// Button for single payment user
else
// Button for recurring payment user
}
[/hilite]

I hope that helps. :)

Posted: Saturday Mar 10th, 2012 at 6:55 pm #7846
bigt11
Username: bigt11

@cristian it seems that your code snip-it will just see if they have any paypal transaction associated with there account. What im looking for is this.

imagine both users are registered on my site and both level 1. User A got to level 1 by a single payment method. User B got to level 1 via a recurring payment method.

I want some conditional to check if user A, or B got to level 1 via the recurring payment method, or vice versa.

I want single payment users to see different data than recurring payment users.

Posted: Saturday Mar 10th, 2012 at 7:19 pm #7847
bigt11
Username: bigt11

I might take it back, im not 100% sure, but I believe recurring subscriptions have an “I-THE_REST_OF_THE_ID”. So the “I-” means that it is recurring, so i guess i can check for the “I-”

Can you confirm this?

Posted: Saturday Mar 10th, 2012 at 7:45 pm #7848
bigt11
Username: bigt11

This seems to do the trick assuming that the I- assumption is correct. Is there a better way to do this using built in s2 member code?

$TAO_s2member_subscriber_id = S2MEMBER_CURRENT_USER_SUBSCR_ID;
$TAO_recurring_member_id_key = "-";
echo $TAO_s2member_subscriber_id;
echo "<br>";
$TAO_seach_for_recurring = strstr($TAO_s2member_subscriber_id,$TAO_recurring_member_id_key, true);

if($TAO_seach_for_recurring == "I" )
	{
			
		echo "you are a recurring payer";
		
	}
	
else
	{
		echo "You are a single payer";	
	}
Posted: Tuesday Mar 13th, 2012 at 5:00 am #7950

Ah, sorry I didn’t understand earlier.

Yeah, if the recurring ones are prefixed with an I-, then your code should be fine.

About suggesting a variation, it’d probably be to make it shorter, if you care about that:

[hilite pre_code]
if (strstr(S2MEMBER_CURRENT_USER_SUBSCR_ID, '-', true) == 'I')
echo 'you are a recurring payer.';
else
echo 'You are a single payer.';
[/hilite]
Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

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.