Mostly clients wants common request that they are able to have page that can be only accessed by specific roles likes authors, contributors etc. Today i am going to share with you a quick tip to create a page template that only authors can access.
For restrict user access you have to simply create a new page template and paste the following at the very beginning of the file:
<?php
/* Template Name: Restricted to Authors only */
if ( !current_user_can('author')) {
wp_die('You don’t have access to this page.')
}
?>
Thanks to Kevin Chard for this snippet!
If you enjoyed this article, please consider sharing it!!
The post How to Restrict User Access to Specific Templates! appeared first on WordPress Experts.