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.

Award CCAP based on time?

Home Forums Community Forum Award CCAP based on time?

This topic contains 22 replies, has 4 voices. Last updated by  Cristián Lávaque 3 years, 7 months ago.

Topic Author Topic
Posted: Tuesday Apr 30th, 2013 at 5:48 am #48789

Greetings s2Member Customer Support Forums,

I’m looking for a much nicer solution to a system we operate that drip feeds content to members, over the course of months, that is also broken down into weeks and days.

Currently, we’re using the recommended method that drip feeds content to people based on their paid registration time, which I feel has two major issues:

1) The user technically can access to the content, but simply isn’t being shown the content. If someone else was to give them a link, they could see the content, and we don’t want that breech to be an option.

2) It isn’t trackable and editable. Having content drip through user registration time, if something goes wrong, it would be very hard to see exactly where everything went wrong. Using CCAP I can clearly see on their profile, if they’ve been given that months teachings or not.

So, with those two concerns, I’m looking for a system that pretty much does this (on a Cron Job, if needed):

If Paid Member for 1 Day
{Give CCAP #1}

If Paid Member for 2 Days
{Give CCAP #2}

If Paid Member for 3 Days
{Give CCAP #3}

If Paid Member for 4 Days
{Give CCAP #4}

List Of Topic Replies

Viewing 22 replies - 1 through 22 (of 22 total)
Author Replies
Author Replies
Posted: Tuesday Apr 30th, 2013 at 10:36 am #48796

Additional Support Needed!

While this problem isn’t related to the one above, I wanted to grab a member of staff while they’re here, so they can help me resolve this problem also.

I’m currently experiencing a very odd situation when it comes to my PayPal Pro Forms. When logged in as an Administrator, the form is presented in the correct manner, the nice icons, layout and the important information, such as Name, Email Address & Payment Gateways are presented.

This can be seen here: http://i.imgur.com/gj3Mccf.jpg

Alternatively, when accessing this page logged in as anything other then an Administrator, the form is not styled at all, and the look is totally ruined. None of the icons load, and nothing functions.

Looking at the issue with Firebug, I can see what the CSS is just not loading at all, but I think this might be down to the fact that the form seems to believe I am not logged in, despite checking several times. I’ve even used sections of code to ensure, by making it only visible when logged in.

The result can be seen here: http://i.imgur.com/Du3tGaS.jpg

I’ve no idea why the CSS is loading on the form only for Administrators, but that clearly indicates to me that there is not a plugin conflicting, as it works in one scenario, and not the other.

Any support, would be fantastic. Thanks.

Posted: Tuesday Apr 30th, 2013 at 12:04 pm #48799
cassel
Username: cassel

I am not 100% sure it will address your first request, but there is a hack available that will use a ccap based on the time of purchase, and not registration, and can be used for dripping content. There is a thread about it here:
http://www.s2member.com/forums/topic/ccap-drip-timer-drip-multiple-courses/
It allows a user to register at one time and purchase the membership at another time and have the dripping based on the purchase time.
It also allows the user to have more than one course, concurrent, even if the time of purchase is different.

I am using that hack on my site and content is dripped on a weekly basis, so if member A has been a member since 20 weeks, he will see the content for weeks 1 to 20, but if member B has been a member since only 3 week, they will only see the content for weeks 1-3. And if the link is shared, it wont matter since it checks for the specific ccap of the user.

And if you need some tweaking of the hack, the programmer can do that for you too.

Posted: Tuesday Apr 30th, 2013 at 1:49 pm #48804

Thanks Cassel,

Sadly, I don’t really want to invest any money into this solution, as I know something like this could be achieved easily using one of the intelligent members of the s2Member Staff.

I’ve run a hack before that promoted people automatically over time, with the same parameters that I want, but we changed our design intention from membership levels, to Custom Capabilities. The problem is when I tried to convert it myself, it didn’t function.

Thanks again for the support though.

Posted: Wednesday May 1st, 2013 at 5:26 am #48892

Any Staff able to update me on the two issues I am having?

Posted: Wednesday May 1st, 2013 at 10:22 am #48910

I’m sorry to bump this thread again, but the situation is getting rather critical now, and the issue with the PayPal Form remains, and the CCAP Over Time System I’ve tried with another hack is not functioning at all.

Posted: Wednesday May 1st, 2013 at 5:04 pm #48945

Several other topics are getting some attention, and I wanted to just ensure this thread isn’t lost. The two problems I am facing are critical to our company, and I’d like help resolving them as soon as possible.

I know the folks at s2Member are busy, but a few moments to resolve these issues would be great. Thank you.

Posted: Wednesday May 1st, 2013 at 9:23 pm #48958
Eduan
Username: Eduan
Moderator

Hello there,

I read your question, and I can see your concerns. To answer your first question, you would simply need to have some PHP that depends on these drip conditionals that s2Member has.

If a certain drip conditional is true then simply with some PHP magic give the user the ccap that you wish. You can figure out the PHP needed for this checking the s2Member codex: s2Member® » Codex (Source Code Docs)

To answer your second question, I’m not sure what cold be causing this issue. Could you please try these common troubleshooting tips: Knowledge Base » Common Troubleshooting Tips

– Eduan

Posted: Wednesday May 1st, 2013 at 11:27 pm #48981

So, with those two concerns, I’m looking for a system that pretty much does this (on a Cron Job, if needed):

If Paid Member for 1 Day
{Give CCAP #1}

You can combine the conditionals approach with some code that’ll add those ccaps instead of showing the content. See: Knowledge Base » Changing Roles/Capabilities via PHP

I’ve run a hack before that promoted people automatically over time, with the same parameters that I want, but we changed our design intention from membership levels, to Custom Capabilities. The problem is when I tried to convert it myself, it didn’t function.

So I’m guessing you based it on the above article’s tip. It’d be pretty much the same but adding capabilities instead of changing roles.

Show me your code, please. You can post it inside <code></code> tags.

Posted: Thursday May 2nd, 2013 at 3:06 am #48999

Greetings,

Thanks for the responses. In response to your Cristian, I’m using a bit of code you’ve developed for me before, and you can see it here:

<?php 
if(current_user_is('s2member_level1') && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 30) { 
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->set_role('s2member_level2');
} 
?>

Essentially, what I want there is then award the Custom Capabilities, instead of upgrading their Membership Level. However! The one issue this system did have, was that the Administrator Account was also constantly being promoted, demoted, and moved around. Is there anyway we could code in so that the Administrator Account is ignored, or set as Administrator every time this is run?

To Eduan, I’ve run all the troubleshooting, turned off all plugins and support systems that are not critical to our site. A lot of our site has been built bespoke, and around a lot of certain functionality.

The only remaining plugins however, shouldn’t have any impact on the CSS. I’d much rather leave that as a last ditch attempt, as I don’t wish to start messing with the site, and removing core features only to have to spend a few more hours fixing it later.

As I said, I’m confused as to why the CSS is just not loading on the Pro Form, yet it does for the Administrator Account. However, even on the Administrator Account, the PayPal & Payment Options box is always present, choosing PayPal doesn’t hide the Card Details box.

Posted: Thursday May 2nd, 2013 at 4:44 pm #49035

Just looking to see if there is any update or response to the issue I posted, and any help with the code I posted.

Thanks!

Posted: Thursday May 2nd, 2013 at 6:48 pm #49057

Essentially, what I want there is then award the Custom Capabilities, instead of upgrading their Membership Level.

Sure. It’s explained in the article I linked to. Here’s an example from it:

[hilite pre_code]
add_cap("access_s2member_ccap_videos");
$user->remove_cap("access_s2member_level2");
?>
[/hilite]

So in the code you had, change the line that sets the role, to the one that adds the capabilitiy.

However! The one issue this system did have, was that the Administrator Account was also constantly being promoted, demoted, and moved around. Is there anyway we could code in so that the Administrator Account is ignored, or set as Administrator every time this is run?

Of course. The conditionaly you had should not have been true for an administrator, because [hilite mono]current_user_is('s2member_level1')[/hilite] checks if the user has the role s2member_level1, which is not the role administrator. To be sure, though, you can add to your conditional a check that makes sure that the user isn’t an administrator.

Posted: Friday May 3rd, 2013 at 2:36 am #49090

Fantastic, Thanks.

However, is there anything you can think of, as to why the Style Sheet is not loading for everyone else, but only the Administrator?

I’ve run a clean install, and it hasn’t worked. You can see the page for yourself here; http://thegoldenwarriorsoflight.com/membership-registration/GBP/

Posted: Friday May 3rd, 2013 at 2:51 am #49097

I’ve run a clean install, and it hasn’t worked. You can see the page for yourself here; http://thegoldenwarriorsoflight.com/membership-registration/GBP/

That’s not a clean installation, it has a custom theme. Try with the default theme, please.

If you added any plugins other than s2Member, please deactivate them for the test too.

Knowledge Base » Common Troubleshooting Tips

That should have the pro-form working/looking correctly again. Then you can add things one by one, reloading the pro-form page after each to check if the problem returned with your last addition.

Posted: Friday May 3rd, 2013 at 3:22 am #49101

Okay. I’ve deactivated Better WP Security, and that has fixed the issue to a degree. Sadly, the PayPal & Card Details section is not operating properly.

When clicking on PayPal, I assume the Card Details box is not meant to be visible. I’ll continue to try a few more plugins, but some of the remaining plugins are critical to our operations.

Quick Question; Do you have any idea as to why it would be Better WP Security causing this issue?

Resolved!

It was a combination of Better WP Security & WP e-Commerce. We were using WP e-Commerce as a one off payment system, but I think I’ll just convert the Web store System to support s2Member and use the Buy Now functionality.

Posted: Friday May 3rd, 2013 at 3:40 am #49102

Quick question then about formatting this CCAP System.

Would this work fine, and be an effective way of handling it, or is there a better way to have this system?

<?php 
if(current_user_is('s2member_level2') && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 1) { 
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->add_cap("access_s2member_ccap_product1");
} 
?>
<?php 
if(current_user_is('s2member_level2') && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 7) { 
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->add_cap("access_s2member_ccap_product2");
} 
?>
<?php 
if(current_user_is('s2member_level2') && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 31) { 
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->add_cap("access_s2member_ccap_product3");
} 
?>
<?php 
if(current_user_is('s2member_level2') && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 39) { 
	$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
	$user->add_cap("access_s2member_ccap_product4");
} 
?>
Posted: Friday May 3rd, 2013 at 2:14 pm #49139

Resolved!

Great! Glad you found the conflict causing you the problem.

Would this work fine, and be an effective way of handling it, or is there a better way to have this system?

To drip the ccaps? That would be fine, but that code will keep adding the cap without checking if he already had it.

Maybe you could do something like this (haven’t tested it):

[hilite pre_code]
'product1',
7 => 'product2',
31 => 'product3',
39 => 'product4',
);

foreach ($days_ccap as $days => $ccap) {
if (!current_user_can('access_s2member_ccap_'.$ccap) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= $days) {
$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
$user->add_cap('access_s2member_ccap_'.$ccap);
}
}
}
?>
[/hilite]

Posted: Friday May 10th, 2013 at 5:16 am #49679

Greetings,

I’ve made a small change to the way in which it selects the user, and the code is no longer turning up any errors. This is great news, except currently it is not awarding anyone with the Custom Capabilities.

Now, my initial testing is related to a situation where this new system is operating on customers who’ve already been been a member for some time, and I’ve yet to test it over 24 hours (1 day) to see if it works then.

I’ll put the code here, so if anyone else is interested, or has any recommendations, they can let me know. I’ll update this thread again on Monday, with any new issues or problems.

<?php if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL == 2){

	$days_ccap = array(
	
		1  => 'product1',
		7  => 'product2',
		31 => 'product3',
		39 => 'product4',
		
	);

	foreach ($days_ccap as $days => $ccap) {
	
		if (!current_user_can('access_s2member_ccap_'.$ccap) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= $days) {
		
			$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
			
			$user->add_cap('access_s2member_ccap_'.$ccap);
		}
	}
}
?>
Posted: Wednesday May 15th, 2013 at 10:31 am #50017

The system isn’t working as intended, any possible fix?

Posted: Tuesday May 21st, 2013 at 8:59 am #50287

Greetings,

I’ve done some testing with this system, and I’ve done everything I can to debug the code, but for some reason it isn’t working. I’ve made another test payment via PayPal to ensure that this system is working with Express Checkout or Website Payment Pro, but so far nothing has been working.

No errors along the way, no issues and no problems, just the Custom Capabilities are not being assigned. I fear this may be due to the code not functioning properly. Any chance someone could take a look at it?

<?php if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL == 2){

	$days_ccap = array(
	
		1  => 'product1',
		7  => 'product2',
		31 => 'product3',
		39 => 'product4',
		
	);

	foreach ($days_ccap as $days => $ccap) {
	
		if (!current_user_can('access_s2member_ccap_'.$ccap) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= $days) {
		
			$user = new WP_User(S2MEMBER_CURRENT_USER_ID);
			
			$user->add_cap('access_s2member_ccap_'.$ccap);
		}
	}
}
?>
Posted: Wednesday May 22nd, 2013 at 8:12 am #50366

Just bumping the thread, as I’d really like a solution to this issue. I’m looking for a way to reward people with CCAPS based on their Level and how long they’ve been a member!

Thank you!

Posted: Friday May 24th, 2013 at 3:58 am #50542

Just bumping this thread again, as I really need an answer before the s2Member Staff Team go for their Weekend!

Posted: Friday May 24th, 2013 at 9:03 pm #50589

I’m sorry, this is not an issue with s2Member and we don’t offer customization services. s2Member® » Support Policy » Fine Lines

Have you considered getting a freelancer to help you? You can post a job in sites like jobs.wordpress.net, elance.com or odesk.com.

Viewing 22 replies - 1 through 22 (of 22 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.