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 Capability With Categories

Home Forums Community Forum Custom Capability With Categories

This topic contains 9 replies, has 2 voices. Last updated by  Raam Dev 4 years, 9 months ago.

Topic Author Topic
Posted: Wednesday Apr 4th, 2012 at 4:40 am #10019
Angela Zou
Username: angelaz

I need users to be able to create their own protected content, so I thought of custom capability (no cascading privileges like when using membership levels) based on category (all contents of this category), but I’m not sure how I can do this. Or if S2member has this feature built-in?

Edit: In addition, I also need to find how can I insert my custom code when a new user has been registered with the API (I want to use the Registration Notification, but I’m not sure if it works if I register a new user using the API instead of the default wordpress form)

  • This topic was modified 4 years, 9 months ago by  Angela Zou.

List Of Topic Replies

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Wednesday Apr 4th, 2012 at 2:52 pm #10056
Raam Dev
Username: Raam
Staff Member

Hi Angela,

The s2Member Level roles use the WordPress ‘Subscriber’ role for their capabilities. As a result, s2Member has not been designed to allow users to edit or post content (e.g., Author role).

If you’d like to modify the default capabilities of an s2Member role, you can do so with a WordPress Role Editor plugin, but this is not supported by s2Member. You’ll also need to keep several security precautions in mind if you decide to do this. Please see this thread for more information.

Regarding your second question, I believe the Signup Notifications should work for this (Dashboard -› s2Member® -› API / Notifications -› Signup Notifications), but I’ll have to double-check with Jason.

Posted: Thursday Apr 5th, 2012 at 3:15 am #10126
Angela Zou
Username: angelaz

but every time the user finishes the payment, they would return to the website. (I’m only concerned about the Alipay gateway.) Doesn’t the URL keep some information (like how much they’ve charged) so I can use the appropriate hook/filter to update that information to the custom field value?

Posted: Friday Apr 6th, 2012 at 8:43 am #10233
Angela Zou
Username: angelaz

I forgot to ask, how can I set up a custom capability for the user via script? I know I should either update a meta_value field in the usermeta table, but I’m not sure how to insert a new element into the already serialized array. Also, I wasn’t able to find the custom capability data that I entered, is this even stored somewhere?

Posted: Friday Apr 6th, 2012 at 11:36 am #10245
Raam Dev
Username: Raam
Staff Member

Hi Angela,

The Custom Capabilities are saved in the user_meta table in a serialized array, so working with that data will be difficult. You can see more about extracting the Custom Capabilities via PHP here.

We’re working to improve the way these are stored in the database for the next major release of s2Member. Until then, you’ll need to write your own code to extract and parse the serialized array.

As per our support policy (see s2Member® » Support Policy » Outside Scope), assistance with coding for such custom features is not supported.

Posted: Friday Apr 6th, 2012 at 11:54 pm #10267
Angela Zou
Username: angelaz

but you still haven’t mentioned what is the name of the index I should use (for example, if I create a custom field, I can find the array element using the label which becomes the index key of the array). You guys really should write some documentation on this. It’s extremely vague what you are doing with the data and how you are storing it.

Posted: Saturday Apr 7th, 2012 at 3:55 pm #10295
Raam Dev
Username: Raam
Staff Member

Angela,

Inside the wp_usermeta table in your database, there is a meta_key called wp_capabilities that includes the custom capabilities inside a serialized array.

Interacting with the custom capabilities through the database is certainly not ideal and their storage inside a serialized array makes working with them difficult. This was a design flaw with how custom fields were stored. We are working to greatly improve this in the next major release of s2Member. I don’t have any details about exactly how things are changing, but custom capabilities will likely get their own database table instead of being stored in a serialized array.

Also, regarding the Remote API Operations that comes with s2Member Pro:

The Remote Operation ‘create_user‘, allows for a ‘notification‘ directive. If this is a non-zero value (i.e. ‘notification’ => ‘1’), then s2Member/WordPress will process the New User Notification emails. One notification email will go to the site owner (i.e. you have a new User), and another to the User’s email address. This email simply contains the User’s password with instructions on how to log in. These emails can be further customized under: s2Member -> General Options -> Email Configuration.

s2Member’s event-driven API Notifications are something else entirely, not related to the ‘notification‘ directive that I just mentioned.

All accounts created through the Remote Operations API will cause a new API Registration Notification, as configured under: s2Member -> API Notifications -> Registration Notification. But that’s it. Most of the other API Notifications, including the Signup Notification are only related to payment gateway processing, and will NOT be triggered during a simple registration via the Remote Operations API. Only the Registration Notification would be triggered when creating accounts through the Remote Operations API.

Posted: Saturday Apr 7th, 2012 at 11:34 pm #10306
Angela Zou
Username: angelaz

I was meant to ask what “index” should I save it under. For example, normal custom field provide a field where you enter the label, say comp_name and all entries would be comp_name => apex inc, comp_name => runaway home, etc. What is the label for custom capability in the array?

Posted: Monday Apr 9th, 2012 at 6:55 am #10356
Angela Zou
Username: angelaz

never mind, I found it. It’s stored as access_s2member_ccap_CAPNAME => 1 in the wp_capabilities field of the usermeta table. No wonder I couldn’t find it in custom fields…

Posted: Monday Apr 9th, 2012 at 5:24 pm #10383
Raam Dev
Username: Raam
Staff Member

Glad you found it, Angela! Thank you for sharing the solution. :)

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