-2

In WordPress I'd like to restrict the templates that the Editor role can create pages with. If I have 2 templates named Default Template and Advanced Template; how do I make it such that the Admin role has access to build pages off both but the Editor role can just use the "Default Template"?

Any idea how to do this please? Thank you.

User301276
  • 55
  • 1
  • 8

1 Answers1

0

You can unset the templates you want like this.

function remove_page_templates_by_role( $templates ) {

    if( current_user_can('editor')) { 
        unset($templates['your-template.php']); // Change to your template
    }
    return $templates;
}
add_filter( 'theme_page_templates', 'remove_page_templates_by_role' );
Snuffy
  • 1,723
  • 1
  • 5
  • 9