This can be achieved easy enough with just CSS. First we are going to add a function that will output a class to the body tag based on what role the user is. Then we will enqueue a stylesheet to show up in the admin. Then use the class in the body to target and hide the button.
Add Body Class Based on User Role – Add to functions.php
function custom_role_admin_body_class( $classes ) {
global $current_user;
foreach( $current_user->roles as $role )
$classes .= ' role-' . $role;
return trim( $classes );
}
add_filter( 'admin_body_class', 'custom_role_admin_body_class' );
Enqueue Admin Styles – Add to functions.php
function custom_admin_styles(){
wp_enqueue_style(
'admin_css',
get_stylesheet_directory_uri() . '/css/admin-styles.css', array(), filemtime( get_stylesheet_directory() . '/css/admin-styles.css')
);
}
add_action('admin_enqueue_scripts', 'custom_admin_styles');
Use Body Class to Hide Button for NON admin users
body.edit-php.post-type-page:not(.role-administrator) .page-title-action {
display: none;
}