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.

Require Custom Capabilities? Does this work?

Home Forums Community Forum Require Custom Capabilities? Does this work?

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

Topic Author Topic
Posted: Tuesday Jul 3rd, 2012 at 4:43 am #18145

I’d like to use the “Require Custom Capabilities?” feature on page content. I’ve created a custom capability in WordPress using the “User Role Editor” plugin. I’ve titled the custom capability “access_s2member_ccap_domestic” as suggested in the documentation. However, when I go to a page with the text box “Require Custom Capabilities?” and set the content to either “domestic” or “access_s2member_ccap_domestic” a user without that capability can still see the page.

The text under the text box says to “* see: API Scripting -> Custom Capabilities”, but after reading the eight paragraphs of text, I’m still puzzled. The documentation does say “*New* Starting with s2Member v3.2+” -which is silly because no where can I find a version number of “s2Member v3.2+”, my version, according the the plugins screen is “120622”. 120622 doesn’t match the pattern “s2Member v3.2” in any way, shape or form.

Can you clarify how to get this working? I’m either missing something (or perhaps the cryptic, counter-intuitive documentation is just plain wrong?). Any clue would be greatly appreciated.

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Tuesday Jul 3rd, 2012 at 4:52 am #18146

I see the problem now. If I set up two custom capabilities and assign a user a given role, then re-assign his role, the capabilities field (that s2Member generates) simply appends the capabilities but does not clear them. This means that I must clear the s2Member capabilities field anytime I change a user’s role, otherwise the user may still have capabilities from his prior role.

Please consider fixing this and perhaps the documentation to reflect a version number that’s consistent.

Great plugin. Thank you!

Posted: Tuesday Jul 3rd, 2012 at 8:02 am #18184
Raam Dev
Username: Raam
Staff Member

Hi Stephen,

Apologies for the confusion over the incorrect version number. I will let the lead developer know about that and hopefully we’ll get it fixed in the next update.

Regarding Custom Capabilities: These are *not* WordPress capabilities. You don’t create them with the Role Editor plugin. A custom capability is a feature of s2Member that allows you to fine tune your restrictions. Please see the following video:

<Embed Playlist>
Posted: Tuesday Jul 3rd, 2012 at 3:51 pm #18219

Regarding Custom Capabilities: These are *not* WordPress capabilities.

That’s odd. Because the documentation says “offered by WordPress Roles/Capabilities”. The video also says “…WordPress Roles/Capabilities”.

It also appears to work with “WordPress Capabilities”. But there is a bug:

While s2Member generates a “WordPress Capability”. The problem is that when a user’s WordPress Role is associated with a capability and then that capability is revoked, the capability is not removed. This is because s2Member actually stores the capability in the “user capability textbox” as can be seen in the user profile page. However, it does not properly update the user meta information when his or her role is updated.

My solution, as I stated above, is to manually clear the “capabilities” textbox prior to saving the user’s profile page. To automate this, I simply created a jQuery that clears the textbox whenever a role is changed on a given user.

Please consider reviewing the documentation and video above for “WordPress Capability”.

Again, great product. Thank you!

Posted: Wednesday Jul 4th, 2012 at 8:14 am #18279
Raam Dev
Username: Raam
Staff Member

Hi Stephen,

Thank you for the reply. I did a bit more research and I was indeed wrong: the s2Member Custom Capabilities are in fact built upon the WordPress Capabilities. However, the documentation states that “Custom Capabilities are an extension to a feature that already exists in WordPress®”.

s2Member has extended its use of Custom Capabilities to work on a per-user basis. The WordPress use of Capabilities is limited to Roles (at least from a UI standpoint; I checked the WordPress documentation and it also makes no mention of assigning capabilities to users)

By being able to assign individual capabilities to users, s2Member allows you to effectively sell features on a one-time basis, adding and removing Custom Capabilities as necessary.

s2Member’s UI does not allow you to assign its Custom Capabilities to Roles; it expects that you will be using them on a per-user basis. That’s why when you generate a Pro-Form that includes Custom Capabilities, you need to explicitly state that you want to remove all existing Custom Capabilities from the user signing up (or upgrading) with the form before adding the new ones (if that’s actually what you want to happen).

If you click the question mark next to the Custom Capabilities box on one of the Pro-Form generators (Dashboard -› s2Member® -› PayPal® Pro Forms), here’s what it says:

Optional. This is VERY advanced.
See: s2Member -> API Scripting -> Custom Capabilities.

*ADVANCED TIP: You can specifiy a list of Custom Capabilities that will be (Added) with this purchase. Or, you could tell s2Member to (Remove All) Custom Capabilities that may or may not already exist for a particular Member, and (Add) only the new ones that you specify. To do this, just start your list of Custom Capabilities with `-all`.

So instead of just (Adding) Custom Capabilities:
music,videos,archives,gifts

You could (Remove All) that may already exist, and then (Add) new ones:
-all,calendar,forums,tools

Or to just (Remove All) and (Add) nothing:
-all

I hope this clears things up a bit! :)

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