WordPress Snippets at WPcustoms

Restrict template parts to specific user class

Use this in a custom template page to restrict page content to specified user role.


/**
 * Snippet Name: Restrict template parts to specific user class
 * Snippet URL: https://wpcustoms.net/snippets/restrict-template-parts-to-specific-user-class/
 */
       if ( !current_user_can('author')) {
    echo 'This page is restricted to authors only';
     } else {
	// show this to authors
	}