Page 1 of 1

Dev'l Question: Does S2member check for role or capbility?

PostPosted: June 21st, 2011, 10:13 pm
by dwdutch
I have users assigned to the S2member Level 2 role and I have Custom Registration Fields that are restricted to users with this role.

In addition I have a special capability for which i want a handful of my S2member Level 2 users to have access. Since the majority with that role will NOT have access to the new capability, I left the s2member Level 2 role untouched and I created a new role (called Board Member) to which I assigned my one additional special capability PLUS all of the same capabilities as the s2member Level 2 role (i.e. ACCESS_S2MEMBER_LEVEL0, ACCESS_S2MEMBER_LEVEL1 and ACCESS_S2MEMBER_LEVEL2).

HOWEVER, I noticed that those assigned the new role (i.e. Board Member) cannot complete changes in their USER PROFILE for the Custom Registration Fields. The fields are visible in the USER PROFILE but when the user changes the field then submits the page, the field changes are NOT saved.

So, my questions...

To accept User Profile changes, does S2member rely on checking the ROLE of the user -or- on checking the ACCESS_S2MEMBER_LEVEL2 capability?

Is there a work-around to allow a new role that includes the ACCESS_S2MEMBER_LEVEL2 capability to still complete changes in the Custom Registration Fields of the USER PROFILE?

I have S2member Version: 110620 and WP 3.1.3

Re: Dev'l Question: Does S2member check for role or capbilit

PostPosted: June 22nd, 2011, 12:59 am
by Cristián Lávaque
Well, I don't know how the custom field check is done, whether role or capability, but I can suggest that instead of giving that handful of users another role, you just edit their profiles to add the new custom capability. You can do it by hand in their profiles or in bulk using the Import tool if you have s2Member Pro.

Re: Dev'l Question: Does S2member check for role or capbilit

PostPosted: June 22nd, 2011, 8:53 pm
by dwdutch
Thanks for he suggestions; however, I think it is appropriate to define a new ROLE in this case. To simplify this support-question, I described ONE new capability - in actuality, I have a handful of users who will support GRAVITY FORMS within my blog. That particular plug-in introduces 18 additional capabilities! I want to give this power to our board-members as they rotate in/out of various positions and I want our non-technical admin to be able to manage this assignment. For that reason, it is much easier if she only has to change the role assignment.

Re: Dev'l Question: Does S2member check for role or capbilit

PostPosted: June 25th, 2011, 1:27 am
by Jason Caldwell
Thanks for the excellent question.
I can't say that this configuration is going to work fully as expected in all aspects of s2Member, because s2Member DOES expect all "Members" to have one of the s2Member Roles, and/or the Subscriber Role. But in the specific scenario that you pointed out, you could try this hack to get things working.

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
add_action
("ws_plugin__s2member_before_custom_fields_configured_at_level", "my_function");
function my_function($vars = array()){
if(
current_user_is("board_member"))
   $vars["__refs"]["level"] = 2;
}
?>