admin管理员组

文章数量:1277405

At first sorry for my bad English! I try to hide #mceu_27-body and #wp-content-editor-tools on products page (editing mode) like on the pics for certains authors! This work find :

    add_action('admin_head', 'wwc_my_custom_css');
if (!current_user_can('edit_pages') ) {
function wwc_my_custom_css() {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';}
}

But it affect all posts type and I just want it on products post type so I tried that but it doesn't work :

add_action('admin_head', 'wwc_my_custom_css');

if (!current_user_can('edit_pages') && is_product() ) 
function wwc_my_custom_css() {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';}
}

Thx

At first sorry for my bad English! I try to hide #mceu_27-body and #wp-content-editor-tools on products page (editing mode) like on the pics for certains authors! This work find :

    add_action('admin_head', 'wwc_my_custom_css');
if (!current_user_can('edit_pages') ) {
function wwc_my_custom_css() {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';}
}

But it affect all posts type and I just want it on products post type so I tried that but it doesn't work :

add_action('admin_head', 'wwc_my_custom_css');

if (!current_user_can('edit_pages') && is_product() ) 
function wwc_my_custom_css() {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';}
}

Thx

Share Improve this question edited Nov 12, 2021 at 22:40 vancoder 7,92428 silver badges35 bronze badges asked Nov 11, 2021 at 20:23 Fanto masFanto mas 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

I assume you mean to use this on a single product's page, right? If so, try this:

add_action('admin_head', 'wwc_my_custom_css');

function wwc_my_custom_css() {
if (!current_user_can('edit_pages'){
   global $post;
   $isProduct = $post->post_type == 'product'; // use the actual name for product

   if ($isProduct ) {
     echo '<style>
               #mceu_27-body, #wp-content-editor-tools{
                  display:none !important;
               }
          </style>';
     }
  }
}

本文标签: postsTarget only single product page