Italian (Italy)
Knowledge Base  >  Vik Appointments  >  Hook  >  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.
Ultimo aggiornamento: 2021-10-04
Utile?
100% delle persone lo ha trovato utile.