I added the capabilities now through this code. I’m not happy with my solution and it would be great if someone could find a proper way to add to the filter. I would be honestly interested to know how to make it properly work.
add_action( 'admin_init', 'jp_add_atum_caps_to_shop_manager');
function jp_add_atum_caps_to_shop_manager() {
if(!user_can( 217 , 'atum_read_inbound_stock')) {
$capabilities = array(
// Purchase price caps.
'edit_purchase_price',
'view_purchase_price',
// Inbound Stock caps.
'read_inbound_stock',
// Out Stock Threshold caps.
'edit_out_stock_threshold',
// Settings caps.
'manage_settings',
'edit_visual_settings',
// ATUM menus caps.
'view_admin_menu',
'view_admin_bar_menu',
// Other caps.
'export_data',
'view_statistics',
);
// Add the ATUM prefix to all the capabilities.
$capabilities = preg_filter( '/^/', 'atum_' , $capabilities );
$admin_role = get_role( 'shop_manager' );
foreach ( $capabilities as $cap ) {
$admin_role->add_cap( $cap );
}
}
}