Visibility per role hooks
This page lists the 5 hooks of this group. Each entry shows its type, the version it arrived in, where it runs, its arguments and a starting point.
adba_menu_role_layoutadba_protected_itemsadba_simple_profile_autoadba_visibility_collectorsadba_visibility_types
adba_menu_role_layout
FilterSince 2.11.0 Runs in src/Visibility/MenuModel.php.
Filters the menu layout of a role: the groups, order and labels the sidebar uses for users with that role. Null means the role follows the general layout. Role presets can fill a layout here without storing it.
| Argument | Type | Description |
|---|---|---|
$layout | array{groups: array<int, array{id: string, label: string, items: string[], icon?: string}>, order: string[], labels: array<string, string>}|null | Layout of the role, or null. |
$role | string | First role of the user with a layout, or the first role. |
$roles | string[] | All roles of the user. |
add_filter( 'adba_menu_role_layout', function ( $layout, $role, $roles ) {
return $layout;
}, 10, 3 );
adba_protected_items
FilterSince 1.3.0 Runs in src/Visibility/RuleEngine.php.
Filters the items that can never be hidden, as type => item ids.
Only adding works: Addofy's own protected items (its menu) are always put back.
| Argument | Type | Description |
|---|---|---|
$items | array<string, string[]> | Item ids per type. |
add_filter( 'adba_protected_items', function ( $items ) {
return $items;
} );
adba_simple_profile_auto
FilterSince 2.24.0 Runs in src/Visibility/RuleEngine.php.
Filters the profile Automatic picks for a user: shop when WooCommerce is active and the user has edit_shop_orders, editorial otherwise. Return the id of a registered profile (see adba_simple_profiles). Only used when the user and their roles chose Automatic.
| Argument | Type | Description |
|---|---|---|
$profile | string | Picked profile id. |
$user_id | int | User id. |
add_filter( 'adba_simple_profile_auto', function ( $profile, $user_id ) {
return $profile;
}, 10, 2 );
adba_visibility_collectors
FilterSince 1.3.0 Runs in src/Modules/Visibility/Visibility.php.
Filters the collectors that record menu items, meta boxes and other items for the Visibility tab.
Each entry is a class name that implements CollectorInterface (extend AbstractCollector). It is built with the plugin resolver and the registry, and only on admin GET requests by an administrator. Record items of a type added through adba_visibility_types and hide them yourself with RuleEngine::is_hidden().
| Argument | Type | Description |
|---|---|---|
$collectors | array<int, class-string<CollectorInterface>> | Collector class names. |
add_filter( 'adba_visibility_collectors', function ( $collectors ) {
return $collectors;
} );
adba_visibility_types
FilterSince 1.3.0 Runs in src/Visibility/Registry.php.
Filters the item types of the Visibility tab, as type => label.
Add a type (lowercase letters, digits and _) to give it its own section in the tab, in the export and in the registry. Addofy applies rules only to its own six types: hide items of your type yourself, with adba( 'rules' )->is_hidden( $type, $id ). Built-in types cannot be removed.
| Argument | Type | Description |
|---|---|---|
$labels | array<string, string> | Labels keyed by type. |
add_filter( 'adba_visibility_types', function ( $labels ) {
return $labels;
} );