Tricks

Conditionally hide an admin panel widget

Jun 9, 2022
Andrew Peacock
Admin panel

If you need to conditionally hide a widget, use the canView() method:

class MyWidget extends Widget
{
...
 
public static function canView(): bool
{
if ($condition) {
return true;
} else {
return false;
}
}
}

No comments yet…