do_action( ‘admin_page_access_denied’ )

Fires when access to an admin page is denied.

More Information

admin_page_access_denied is an action hook triggered when an user does not have permission to access a page in the control panel. This is most likely due to not having the required capability to access the page.

The action hook is fired before wp_die is executed, and is a result of the function user_can_access_admin_page returning false.

Basic Examples

function mwb_permission_error() {

wp_redirect( site_url() );
exit;

}

add_action( 'admin_page_access_denied', 'mwb_permission_error');

Source

do_action( 'admin_page_access_denied' );

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.