• Resolved grungyape

    (@grungyape)


    The feature to restrict page content based on member roles works 100% as written, but we have a large list of roles and while not frequent, they can be removed or added to.

    Therefore using this option is very cumbersome.

    In reality, what we need to do is “block” the 5 built in roles we do NOT want to have access. This list will never change. It is used to alert us that our NT integration did not properly assign a custom WP role and the user was brought into the system on a default WP role.

    Unfortunately, Members seems to only allow, not block. Is there a work around, an alternative, or perhaps room for a feature upgrade here?

Viewing 1 replies (of 1 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @grungyape

    Sorry for a bit slow response to your question.

    You can try to use this code snippet and insert it at the end of your theme’s functions.php file:

    add_filter('members_can_user_view_post', function($can_view, $user_id, $post_id) {
        $roles = members_get_post_roles( $post_id );
    		$can_view = true;
    
        if ( ! empty( $roles ) && is_array( $roles ) ) {
          foreach ( $roles as $role ) {
            if ( members_user_has_role( $user_id, $role ) ) {
              $can_view = false;
              break;
            }
          }
        }
    
        return $can_view;
      }, 10, 3);

    Hopefully, that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Reverse Content Permissions (i.e. Block)’ is closed to new replies.