Home › Forums › Front End PM PRO › Group Visibility (Role Restriction) In personal settings › Reply To: Group Visibility (Role Restriction) In personal settings
September 5, 2018 at 10:26 pm
#17270
Shamim Hasan
Keymaster
Add following code in your theme’s (child theme’s if any) functions.php
add_filter( 'fep_get_option', function( $value, $option, $default, $is_default ) {
if ( 'gm_groups' !== $option ) {
return $value;
}
if ( is_admin() && 'users' !== @get_current_screen()->parent_base ) {
return $value;
}
if ( ! is_admin() && 'settings' !== @$_GET['fepaction'] ) {
return $value;
}
// Change this with which role you want to give access to all groups
$allowed_roles = array( 'editor', 'administrator' );
if ( array_intersect( $allowed_roles, wp_get_current_user()->roles ) ) {
return $value;
}
// Change this with your desire groups slug
$groups = array( 'test1', 'test2' );
foreach ( $groups as $group ) {
unset( $value[ $group ] );
}
return $value;
}, 10, 4 );
Change roles and groups as required