How can I catch WordPress custom settings page slug has already changed?

56 Views Asked by At

I created a custom settings page like below.

    add_menu_page(
      __('Management', 'domain'),
      __('Management', 'domain'),
      'activate_plugins',
      'management', // <---
      function () {
        echo 'Hello';
      },
      'icon',
      999
    );

As we can see, this page is accessed via the "admin.php?page=management" link. I commented above with "<---" But this is such a page that users can change this slug.

  • For example, let's make this "management-2" and save the form.
  • In this case, WordPress redirects to "admin.php?page=management&settings-updated=true", but since we set it to "management-2", I get a "403" error.
  • At this point I need to catch a hook, start a new redirect and return it to the "admin.php?page=management-2&settings-updated=true" link, but I couldn't find any hook to do this.

Does anyone have any solution suggestions?

0

There are 0 best solutions below