• When attempting to restrict a post by level the options are for Greater than that level.

    Is there a way to restrict a post JUST for a particular level (but not greater than that level – ie just level 3, but not level 3, 4 ,5 etc)?

    Hope that makes sense.
    Cheers.

    https://wordpress.org/plugins/s2member/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yes. You need to install the Capability Manager Enhanced plugin, and then use it to remove capabilities to access lower user levels.

    You’ll also then need to add this to a file called s2hacks.php. This is to stop s2Member restting the capabilities after an update. You you should place this file in your /wp-content/mu-plugins folder:

    <?php
    /*Prevent s2member re-assigning custom capabilities on re-activation*/
    add_filter('ws_plugin__s2member_lock_roles_caps', '__return_true');
    add_action("ws_plugin__s2member_during_add_css", "remove_all_s2_css");
    
    function remove_all_s2_css() {
    	wp_dequeue_style("ws-plugin--s2member");
    }
    ?>

    If no such folder currently exists, you will need to create it.

    Thread Starter Timberyom

    (@tomcazoom)

    Hi, so i added the code, and now users are unable to login to the site at all.

    Its probably because I already have some code in s2hacks preventing ip restrictions for level 7 upwards and added the additional code incorrectly.

    here is my already existing code, how would I add to it?

    <?php 
    
    add_filter('ws_plugin__s2member_disable_specific_ip_restriction', 's2hack_disable_certain_ip_restrictions', 10, 2); 
    
    function s2hack_disable_certain_ip_restrictions ($bool, $vars) {
    	if(username_exists($vars['restriction'])) { // Check if this is a Username
    		$user = new WP_User($vars['restriction']); // This is now a WordPress User Object
    
    		if($user->has_cap('access_s2member_level7')) // If User is s2Member Level 7 or higher, don't run IP Restrictions
    			return true;
    	}
    
    	return false; // If the User doesn't match the needed specifics, then we run IP Restrictions
    }
    
    ?>

    Any idea why and how I can get the site back and running with s2member – maybe I have to install a fresh copy?

    Thread Starter Timberyom

    (@tomcazoom)

    deleted the s2-hack file completely so the site is back up and running with IP restrictions in force for all users which is a bit problematic.

    Help very much appreciated! 🙂

    Thread Starter Timberyom

    (@tomcazoom)

    Just so its clear – I only want to prevent a single level (level 9) from being able to edit their profile. The level will be used by many and it has no ip restrictions. I will stop this level from being able to see certain content using s2 shortcode conditionals – however no level 9 user should be able to edit the profile ie change the password.

    Is there an easier way to prevent a single level from being able to edit their profile/change password – ie through the s2pro login php widget or through wp-login.php?

    Cheers.

    The way I’ve suggested is currently the only way you can do what you want short of custom coding. Honestly, it’s really easy with the plugin I suggested. It sounds like you’d only need to adjust the capabilities for level 9.

    As for why your site had a problem when you added the code I gave you, you didn’t say exactly what the site did when you added the code. If you got the white screen of death, then you probably had some whitespace either before the first <?php tag of after the last ?> tag. You must never do that with a PHP file.

    Thread Starter Timberyom

    (@tomcazoom)

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Restrict post to single level’ is closed to new replies.