I have created a custom post type from a plugin. I added a capability type teacher
. Then I have added custom capabilities to administrator. But the problem is for the first time after completing this code it adds mentioned capabilities to the role. But when I change it further, it doesn't take effect. Like if I now delete the function roles_to_edit_teacher
, still administrator will have the capabilities. So how to solve this issue?
function plugin_main_functions(){ register_post_type('teachers', array( 'labels' => array( 'name'=>__('Teachers List', 'Teachers'), 'add_new' => __('add new teacher', 'Teachers'), 'add_new_item' => __('Add new teacher', 'Teachers') ), 'public' => true, 'supports'=> array('title', 'editor', 'thumbnail'), 'menu_icon' => 'dashicons-groups', 'capability_type' => array('teacher','teachers'), 'map_meta_cap' => true )); } add_action('init','plugin_main_functions'); function roles_to_edit_teacher(){ $admin = get_role('administrator'); $admin->add_cap('edit_teacher'); $admin->add_cap('edit_teachers'); $admin->add_cap('read_teacher'); $admin->add_cap('delete_teacher'); $admin->add_cap('delete_teachers'); $admin->add_cap('publish_teacher'); $admin->add_cap('create_teachers'); } add_action('init', 'roles_to_edit_teacher');