Hook for get_page_templates() - Templates conditionally available based on role

  1. Meditation Man

    Without modifying WP core files, I have not found a way to make page templates conditionally available to different WP admin users.

    On a site with many editors, some page templates are only appropriate for one time use, and it would be great to exclude these templates from the list of available choices when creating or editing a page...for anyone who is lower than an Administrator.

    I imagine a new, optional configuration parameter could be added to the setup of a page template, just under "Template Name:...". It could be something like "Required Role:", and a comma separated list of roles by slug could follow. Then the get_page_templates() function could have some very simple logic that check if the current user has permission to use a template and exclude it from the list of options in Page Attributes metabox if the user does not have permission.

    Of course, if there is already a way to do this with out editing core WP files, I apologize, please steer me in the right direction!

    Posted: 4 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    0 Votes
  • Status

    This idea is under consideration