Reply To: Custom code clash pre update check


Home Forums Front End PM PRO Custom code clash pre update check Reply To: Custom code clash pre update check

#28017
shamim
Keymaster

Hi,
Your most of the code if ok. Last part is changed. You can remove all under “FEPM set Advanced group visibility for selected role.” and add following instead

add_filter( 'fep_get_all_groups', function( $groups ){
	// 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 $groups;
	}
	
	// Change this with your desire group ids
	$restricted_groups = array( 11, 12, 15 );
	
	foreach ( $restricted_groups as $group_id ) {
		unset( $groups[ $group_id ] );
	}
	return $groups;
});

Please note that group slug is no longer relevant. Use group id (post id of that group) instead.

Let me know.