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.

Custom capabilities and member level blank

Home Forums Community Forum Custom capabilities and member level blank

This topic contains 1 reply, has 2 voices. Last updated by  Bruce 3 years, 8 months ago.

Topic Author Topic
Posted: Monday Apr 15th, 2013 at 2:59 pm #47506
Username: wellwater

A few months ago I posted a topic about the custom capabilities and member level not being saved upon a user’s successful payment:

I was using a unofficial auto-login/redirect hack, which Jason suggested could be problematic. Jason also suggested Quick Cache instead of W3 Total Cache.

Since this I’ve switched W3TC for Quick Cache, and have implemented the official “Auto-Login Upon Registration” must-use plugin specified in the knowledge base:

Unfortunately, I’m still occasionally experiencing this problem: registration and signup actions executed, but payment action is not. This results in the user’s account being created, but the membership level stays at “Subscriber” instead of “s2member Level 1” and the custom capabilities field is left blank.

I’ve never been able to duplicate this on a local/dev machine, but it’s happened at least 10-15 times on the live site, including twice today. I see no common characteristic in terms of payment options (happens with paypal and authnet) or browsers.

When Jason originally logged into the site and looked at this, it didn’t appear anything noteworthy was found.

So now I’m trying to find a backup solution to deal with this problem. The vast majority of transactions are successful, but I’m having these intermittent failures and the only time I catch them is when an irate customer emails me about why they can’t access their purchase and then I have to manually update their account, upping the member level and setting the custom capabilities.

So, what I think I need is a way to insert the “wp_capabilities” meta_key in the wp_usermeta table before the payment action is fired off or if the payment action is detected to have not fired off prior to the user being redirected to the “success” url. I notice that s2member will insert this single row which serves the dual purpose of setting a user’s access to the appropriate level and setting one or more custom capabilities.

For example, let’s say a purchase sets the user level to 1 with the custom capabilities of ABC and DEF. s2member will insert the following serialized array as the user’s wp_capabilities:


As I mentioned before “registration” and “signup” actions occur (as reflected in my logs), but “payment” does not, so I want to hook into the “signup” occurrence and have my own PHP script insert the above. This will act as a sort of backup plan incase the failures I’ve experienced happens again. After this failsafe insert takes place, s2member can overwrite or REPLACE it in the database if the “payment” action is ever actually fired off, which’ll likely happen most of the time. If the payment action is not fired off, at least the user will have access to his purchase due to the failsafe.

I know the “signup” and “payment” actions are fired off within milliseconds of each other, so whatever is done needs to happen between these two points. It needs to happen before the user is redirected to the “success” URL, or they’ll get kicked back out due to not having the proper access (member level and custom capability).

The thing is, I’m not sure which is the best approach to doing this. I don’t want to get into an INSERT race condition with s2member, and I’m not even sure if the payment sequence will clash with my wp_capabilities insert due to a wp_capabilities record already existing.

I’m also concerned about how future-proof this is, but I’ve reached the point where I do need a backup solution to this issue which appears to be happening with increased frequency.

By the way, I’m using the latest version of s2member and this problem has occurred in every version since my prior post.


List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Monday Apr 15th, 2013 at 9:45 pm #47565
Username: Bruce
Staff Member

Thank you for your inquiry.

I am forwarding this to our development team to review before the next maintenance release of s2Member, but at this point we’re not aware of any bug in our IPN functionality, and we cannot reproduce this issue.

If you’re looking to create a backup process, I would strongly recommend not editing the database row directly, but instead using the information provided in this Knowledge Base Article regarding changing Roles and Capabilities through PHP. These changes will change the database entry through WordPress.

See: Knowledge Base » Changing Roles/Capabilities via PHP

You might also consider adding a check through Payment Notifications.

See: Dashboard -› s2Member® -› API / Notifications -› Payment Notifications
See Also: Knowledge Base » Building An API Notification Handler

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