Conflict CPT with capabilities not schowing in admin menue
-
Hi,
I have written a mini Plugin for a custom post type. This cpt appears on the admin dashboard menue ONLY if I delete these two lines:
‘capability_type’ => array ( ‘mycupoty’, ‘mycupoty’ ),
‘map_meta_cap’ => true,With these lines INCLUDED the cpt DISAPPEARS from the dashboard menue.
I certainly need the cpt WITH caps assigned. Anyone help me???
The whole plugin looks like this (works fine – except this issue…)
<?php /* Plugin Name: My CPT-plus-Caps-Plugin Plugin URI: https://calaoipee.de Description: Plugin to register the book post type Version: 1.0 Author: Calaoipee Author URI:https://calaoipee.de Textdomain: kastom-posttype License: GPLv2 */ function cpt_mycupoty_init() { $labels = array( 'name' => _x( 'mycupoty', 'custom-post-type-capabilities' ), 'singular_name' => _x( 'mycupoty', 'custom-post-type-capabilities' ), 'menu_name' => _x( 'mycupoty', 'Admin Menu text', 'custom-post-type-capabilities' ), 'name_admin_bar' => _x( 'mycupoty', 'Add New on Toolbar', 'custom-post-type-capabilities' ), 'add_new' => __( 'Add New', 'custom-post-type-capabilities' ), 'add_new_item' => __( 'Add New mycupoty', 'custom-post-type-capabilities' ), 'new_item' => __( 'New mycupoty', 'custom-post-type-capabilities' ), 'edit_item' => __( 'Edit mycupoty', 'custom-post-type-capabilities' ), 'view_item' => __( 'View mycupoty', 'custom-post-type-capabilities' ), 'all_items' => __( 'All mycupoty', 'custom-post-type-capabilities' ), 'search_items' => __( 'Search mycupoty', 'custom-post-type-capabilities' ), 'parent_item_colon' => __( 'Parent mycupoty:', 'custom-post-type-capabilities' ), 'not_found' => __( 'No mycupoty found.', 'custom-post-type-capabilities' ), 'not_found_in_trash' => __( 'No mycupoty found in Trash.', 'custom-post-type-capabilities' ), 'featured_image' => _x( 'mycupoty Cover Image', 'custom-post-type-capabilities' ), 'set_featured_image' => _x( 'Set cover image', 'custom-post-type-capabilities' ), 'remove_featured_image' => _x( 'Remove cover image', 'custom-post-type-capabilities' ), 'use_featured_image' => _x( 'Use as cover image', 'custom-post-type-capabilities' ), 'archives' => _x( 'mycupoty archives', 'custom-post-type-capabilities' ), 'insert_into_item' => _x( 'Insert into mycupoty', 'custom-post-type-capabilities' ), 'uploaded_to_this_item' => _x( 'Uploaded to this mycupoty', 'custom-post-type-capabilities' ), 'filter_items_list' => _x( 'Filter mycupoty list', 'custom-post-type-capabilities' ), 'items_list_navigation' => _x( 'mycupoty list navigation', 'custom-post-type-capabilities' ), 'items_list' => _x( 'mycupoty list', 'custom-post-type-capabilities' ), ); $args = array( 'labels' => $labels, 'public' => true, 'menu_icon' => 'dashicons-welcome-write-blog', 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'mycupoty' ), 'capability_type' => array ( 'mycupoty', 'mycupoty' ), 'map_meta_cap' => true, 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 4, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ), 'show_in_rest' => true, ); register_post_type( 'mycupoty', $args ); } add_action( 'init', 'cpt_mycupoty_init' ); // add the custom capabilities to the desired user roles $roles = array( 'editor','administrator' ); foreach( $roles as $the_role ) { $role = get_role($the_role); $role->add_cap( 'read' ); $role->add_cap( 'read_mycupoty'); $role->add_cap( 'read_private_mycupoty' ); $role->add_cap( 'edit_mycupoty' ); $role->add_cap( 'edit_mycupoty' ); $role->add_cap( 'edit_others_mycupoty' ); $role->add_cap( 'edit_published_mycupoty' ); $role->add_cap( 'publish_mycupoty' ); $role->add_cap( 'delete_others_mycupoty' ); $role->add_cap( 'delete_private_mycupoty' ); $role->add_cap( 'delete_published_mycupoty' ); }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conflict CPT with capabilities not schowing in admin menue’ is closed to new replies.