Big Bugs with Multi Role & Custom Post Type
-
Hello @team,
I detect a big problem with Tutor LMS. Please check it carefully & fix it ASAP.
I have CPT call it: faq
add_action( 'init', 'register_my_cpt_faq' ); function register_my_cpt_faq() { register_post_type( 'faq', array( 'label' => 'faq', 'description' => 'Frequently Asked Questions', 'supports' => array( 'title', 'editor' ), 'hierarchical' => false, 'public' => true, 'exclude_from_search' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-format-chat', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'publicly_queryable' => true, 'show_in_rest' => true, 'map_meta_cap' => false, 'capability_type' => 'faq', 'capabilities' => array( 'edit_post' => 'edit_faq', 'read_post' => 'read_faq', 'delete_post' => 'delete_faq', 'delete_posts' => 'delete_faqs', 'delete_other_posts' => 'delete_other_faqs', 'edit_posts' => 'edit_faqs', 'edit_others_posts' => 'edit_other_faqs', 'publish_posts' => 'publish_faqs', 'read_private_posts' => 'read_private_faqs', 'create_posts' => 'create_faqs', ), ) ); }
I update capability for role Admin like this:
register_activation_hook( __FILE__, 'my_addons_activate' ); function my_addons_activate() { $custom_post_type_permission = array( 'edit_faq', 'read_faq', 'delete_faq', 'delete_faqs', 'delete_other_faqs', 'edit_faqs', 'edit_other_faqs', 'read_private_faqs', 'publish_faqs', 'create_faqs', ); $administrator = get_role( 'administrator' ); if ( $administrator ) { foreach ( $custom_post_type_permission as $cap ) { $administrator->add_cap( $cap ); } } }
With that code, login with Admin and everything’s working perfectly.
But when an Admin user has more than a role (Admin role apply to become instructor and then approved): this user has two roles like this: https://prntscr.com/10yvqqv
And then Admin can’t add/view Custom Post Type FAQ
https://prntscr.com/10yw2ve
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Big Bugs with Multi Role & Custom Post Type’ is closed to new replies.