Cannot access purchased Custom Capability

I’ve installed s2member on my site, and configured PayPal. It’s operating in Sandbox mode, and I was provided a Sandbox email / password to use with PayPal. I’ve also added the following to my wp-config.php:

define( ‘LOCALHOST’, true );

I have a page titled ‘testpage2’, and I used the Custom Capability shortcode generator to create a PayPal button:

[s2If is_user_logged_in()]
Purchase access to this page:
[s2Member-PayPal-Button level="*" ccaps=“testpage2” desc=“Description and pricing details here.” ps=“paypal” lc="" cc=“USD” dg=“0” ns=“1” custom=“jbbu-paywall.crh” ra=“0.01” rp=“1” rt=“L” rr=“BN” image=“default” output=“button” /]

[/s2If]

So far so good. I click through, ‘purchase’ access to the course, and it’s successful. After clicking the “Return to merchant” link in PayPal, it takes me back to my site, and tells me that access should be provided via email, but also tells me that in Sandbox mode, the email won’t be sent out. (In addition, given that I’m developing on my localhost, my dev environment doesn’t have the ability to send emails.)

Back on testpage2, I have the following shortcode:

[s2If current_user_can(access_s2member_ccap_testpage2)]
This Member can access Custom Capability: testpage2
[/s2If]

[s2If !current_user_can(access_s2member_ccap_testpage2)]
This Member can NOT access Custom Capability: testpage2
[/s2If]

Unfortunately, even after I’ve purchased access to Custom Capability testpage2, I am never granted access to the testpage2 content. However, if I modify this WordPress user and manually add the ‘testpage2’ custom capability to the user, the code works as expected and the “purchased” testpage2 content renders.

Obviously I can’t manually update each user after they make a purchase. It appears that purchasing access to the Custom Capability ‘testpage2’ does not update the WordPress user to reflect access to that custom capability.

Does anyone have any insight on how to address this? Thank you in advance.

Hi Chris.

I recommend that you do live transactions for your tests (even if they’re just 1 cent) instead of using the sandbox. https://youtu.be/08t45PYeHxk?list=PL8gPolqFnYqsPh9Y0TCjvwLkKuby29SYg

I also suggest you keep logging enabled while configuring and testing things, to help you troubleshoot if needed. WP Admin > s2Member > Log Files

Try a live test and if you don’t get the ccap added, look up the relevant entries from the log files, so I can take a look at what may be the problem, please.

:slight_smile: