English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Core  >  Before Dispatch

do_action( 'vikappointments_before_dispatch' )

Fires before dispatching the plugin request.


Description

Every time the plugin tries to dispatch a request, this hook is triggered first.

It is useful to require some external libraries, check user global permissions, intercept the dispatched action, inject post variables and so on.


Example

The example below explains how to support a new type of page for the back-end of the plugin. The page will display every time you try to visit the link below.

/wp-admin/admin.php?page=vikappointments&view=mypage
/**
 * Fires before the controller of VikAppointments is dispatched.
 * Useful to require libraries and to check user global permissions.
 */
add_action('vikappointments_before_dispatch', function()
{
    // get current view
    $view = isset($_REQUEST['view']) ? $_REQUEST['view'] : null;

    // check whether the view is supported
    if (is_admin() && $view == 'mypage')
    {
        // display main menu
        AppointmentsHelper::printMenu();

        /**
         * @todo display page contents here
         */
    }
});

Changelog

Version Description
1.0 Introduced.
Last Update: 2021-10-04
Helpful?
100% of people found this helpful.
This site uses cookies. By continuing to browse you accept their use. Further information