根据用户角色显示WordPress页面模板

I want to display page templates dependent on what user is currently logged in (user role).

WordPress has a built in page attributes dropdown selection for templates. Here's an example of the functionality I'm looking for.

Scenario #1: Editor is logged into the WordPress dashboard. They go to create a page. In the page UI they select the dropdown for templates. The drop down only contains templates: A, B, and C.

Scenario #2: Admin is logged into the WordPress dashboard. They go to create a page. In the page UI they select the dropdown for templates. The drop down shows templates: A, B, C, D, and E.

Basically I'm trying to figure out how to display a limited amount of templates based on the user's role and all templates if the user's role is an Admin.

you can use somthing like this:

function get_user_role() {
    global $current_user;

    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);

    return $user_role;
}

then in your html theme you simply put <?php echo get_user_role(); ?>.

it will give you that which user is logged in then u can do whatever you want.