The wp_die() function is a supplement of WordPress to the PHP die() function. It is used to display HTML error messages. For example, when the author role wants to access the topic page, it will display "Sorry, you can't access this page" and terminate the access.
To customize the style and content of prompts, you can add the following code to the current theme function template functions.php:
function custom_error_handler( $error ) { echo '<style>'; Echo '/* Write a custom style here */'; echo 'body { background-color: #F5F5F5; }'; echo '.error-message { color: red; }'; echo '</style>'; Echo '<h1>Error</ h1>'; Echo '<p class="error message">Sorry, you have no permission to access this page!</p>'; exit(); } add_action( 'wp_die_handler', 'custom_error_handler' );
Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!