Skip to content

Snippet: Prevent Editor Access to Dynamic Templates

By default the Dynamic Templates can be edited under Theme Panel > Dynamic Templates, however, site "Editors" don't have access to the Theme Panel so the Dynamic Templates admin link will display at Tools > Dynamic Templates. If you wish to prevent Editors from having access to the dynamic templates you can do so using the following snippet.

/**
 * Remove the Dynamic Templates dashboard for non-admins.
 */
add_filter( 'register_wpex_templates_post_type_args', function( $args ) {
	if ( is_admin() && ! current_user_can( 'edit_theme_options' ) ) {
		$args['show_ui'] = false;
	}
	return $args;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top