Change WordPress user roles and capabilities Forums How to or FAQ Hide Product Content Editor (Visual/Text + Visual Composer) from Role

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2740
    AGB
    Participant

    Hi Vladimir, we have a role (Sales Manager) who needs ability to update product stock quantities, but not other product data. So that role must have edit_products capability but I’m hiding most things.

    Now I need to completely hide the main content editor when this role is on product edit page. Then they will only see the Product Data metabox (I’ll use your post here too).

    We use Visual Composer for all product content. Only Admin can edit content so I have successfully hidden VC from all roles except Admin. But when Sales Manager goes to product edit screen, the content will still display in default WP Visual/Text content editor.

    I saw your post about Removing main text editor … however I would like to only hide it for specified role(s). Can you please help?

    #2742
    Vladimir
    Keymaster

    Hi,

    Try this recipe:

    
    add_action('admin_init', 'remove_product_editor');
    function remove_product_editor() {
    
      if (current_user_can('product-meta-editor')) {
        remove_post_type_support('product', 'editor');
      }
      
    }
    

    Replace role ID ‘product-meta-editor’ with your own as ‘sales-manager’. Add this code to the active theme functions.php file or setup it as a must use plugin.

    #2744
    AGB
    Participant

    Perfect recipe. Thanks Vladimir!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.