For example you are plugin developer and added the list of custom user capabilities, like ‘team_%’. Is it possible to show them in User Role Editor under the ‘Custom Capabiliteis->Team’ group similar to the “User Role Editor” group itself or “WooCommerce” one?
Yes, it’s possible via custom filters. Use the code sample below as a starting point:
add_filter( 'ure_capabilities_groups_tree', 'add_team_group', 10, 1 ); function add_team_group( $groups ) { $groups['team'] = array('caption'=>esc_html__('Team', 'your-text-domain'), 'parent'=>'custom', 'level'=>2); return $groups; } add_filter( 'ure_custom_capability_groups', 'get_team_caps_groups', 10, 2 ); function get_team_caps_groups( $groups, $cap_id ) { $team_caps = array( 'team_cap1', 'team_cap2', 'team_cap3' ); if ( in_array( $cap_id, $team_caps ) ) { $groups[] = 'custom'; $groups[] = 'team'; } return $groups; } |