Custom taxonomy - setting access based on role or capability

后端 未结 1 1299
独厮守ぢ
独厮守ぢ 2021-01-07 10:30

I am only just learning about custom taxonomies for Wordpress. How is it possible to restrict access for my users to use a taxonomy. For instance, I have created a taxonomy

相关标签:
1条回答
  • 2021-01-07 10:48

    Would it be sufficient to remove the metabox from the Post Edit page? If so, give this a whirl:

    function remove_featured_meta() {
       if (!current_user_can('moderate_comments')){
           remove_meta_box( 'featureddiv', 'post', 'side' );
       }
    }
    
    add_action( 'admin_menu' , 'remove_featured_meta' );
    

    You can fill in the conditional statement with whichever appropriate capability corresponds to the user role to which you'd like to limit access to the taxonomy.

    0 讨论(0)
提交回复
热议问题