Is it possible to override a wagtail.hooks.register function with a custom function?

Is it possible to override a wagtail @hooks.register function with a custom function or to de-register a function all together?

One example of what I would like to achieve is editing the register_styleguide_menu_item function in wagtail/contrib/styleguide/wagtail_hooks.py so that the style guide is only shown to superusers.

For example; I would like to override the current function:

@hooks.register("register_settings_menu_item")
def register_styleguide_menu_item():
    return MenuItem(
        _("Styleguide"), reverse("wagtailstyleguide"), icon_name="image", order=1000
    )

with this:

@hooks.register("register_settings_menu_item")
def register_styleguide_menu_item():
    return AdminOnlyMenuItem(
        _("Styleguide"), reverse("wagtailstyleguide"), icon_name="image", order=1000
    )

(note the change from MenuItem to AdminOnlyMenuItem on the third line)

The docs for wagtail hooks are available at https://docs.wagtail.org/en/stable/reference/hooks.html but it doesn't cover this scenario.

Is there a mechanism to achieve this?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum