itthinx / groups

Groups provides group-based user membership management, group-based capabilities and content access control. It integrates standard WordPress capabilities and application-specific capabilities along with an extensive API.
GNU General Public License v3.0
49 stars 35 forks source link

Ability to disable groups on frontend #110

Closed tomislav13 closed 9 months ago

tomislav13 commented 4 years ago

Hi, is there an option to disable this plugin on the frontend? I need it only in the backend, because everyone should see the website, but only specific users should edit(administer) certain parts of website. I made a workaround that seems to work by modifiying file lib/access/class-groups-post-access.php on few places, but is there an option to do this somewhere in plugin config?

ash2osh commented 1 year ago

//this just worked for me

add_filter('groups_user_can', 'xxx_group_open_front_end', 100); function xxx_group_open_front_end($can_access) { if (is_admin()) { return $can_access; } return true; }

itthinx commented 9 months ago

The groups_post_access_user_can_read_post filter can be used returning true when !is_admin() which would effectively override access protections on the frontend.

add_filter( 'groups_post_access_user_can_read_post', 'frontend_override_groups_post_access_user_can_read_post', 10, 3 );
function frontend_override_groups_post_access_user_can_read_post( $result, $post_id, $user_id ) {
    if ( !is_admin() ) {
        $result = true;
    }
    return $result;
}

@ash2osh your solution would open up any capability to the user on the frontend which would create a security issue