Page 1 of 1

Keeping s2member roles during upgrades

PostPosted: October 4th, 2011, 2:18 pm
by dwdutch
I allow certain capabilities within assigned S2Member roles --- for example, the s2member_level2 has the "delete_posts" capability enabled.

I've noticed that on the past couple of upgrades, however, the S2Member roles are "reset" so, that any added capabilities are cleared and I have to remember to go back in to re-assign this capability to those group of users.

Is it possible that future upgrades can simply "retain" the existing assignments allocated to the roles?

Re: Keeping s2member roles during upgrades

PostPosted: October 5th, 2011, 1:53 am
by Cristián Lávaque
Thanks for the feedback. I'll ask Jason about this.

Re: Keeping s2member roles during upgrades

PostPosted: October 8th, 2011, 7:54 pm
by Jason Caldwell
Thanks for the heads up on this thread Cristián.

Yes, you may create this directory and file to lock-in your Roles/Capabilities for s2Member.
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
add_filter
("ws_plugin__s2member_lock_roles_caps", "__return_true");
?>
* This will prevent future upgrades from resetting/re-configuring your Roles/Caps.

In addition, this will disable the Reset Roles/Capabilities button in the Dashboard, under:
s2Member -> General Options -> Membership Levels/Labels. Actually, the button is not disabled completely, but clicking the button does no good, because s2Member will simply return a message indicating that Roles/Capabilities have been locked by this Filter.

Re: Keeping s2member roles during upgrades

PostPosted: October 24th, 2011, 12:46 pm
by dwdutch
Thanks for the feedback. I'll try to remember to re-post my result after the next upgrade opportunity.

By the way, I don't have a multi-user installation of WordPress so I don't have a mu-plugins directory. I just placed the recommended line in my own hacks file.

Re: Keeping s2member roles during upgrades

PostPosted: October 25th, 2011, 4:02 pm
by Jason Caldwell
Sure, thanks for the follow-up, much appreciated!

Note, /wp-content/mu-plugins/ = MUST USE plugins, and this does not require you to have a Multisite installation. MUST USE plugins are an easy way to inject your own code ( i.e. custom plugins ). See: http://codex.wordpress.org/Must_Use_Plugins

Re: Keeping s2member roles during upgrades

PostPosted: November 2nd, 2011, 6:02 pm
by dwdutch
I just did an upgrade and this fix worked wonderfully. Thanks for the info and the clarification on mu-plugins :)

Re: Keeping s2member roles during upgrades

PostPosted: November 3rd, 2011, 11:43 am
by Jason Caldwell
Very welcome. Thanks for reporting back on this!
dwdutch wrote:I just did an upgrade and this fix worked wonderfully. Thanks for the info and the clarification on mu-plugins :)