Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress Registered Post Type Capabilities
<?php
/*
Plugin Name: TSCPL CPT Test
*/
function tscpl_register_teamrooms_cpt() {
/**
* Post Type: Team Rooms.
*/
$labels = array(
"name" => __( "Team Rooms", "" ),
"singular_name" => __( "Team Room", "" ),
"menu_name" => __( "Team Rooms", "" ),
"all_items" => __( "All Reservations", "" ),
"add_new" => __( "Add New", "" ),
"add_new_item" => __( "Add New Reservation", "" ),
"edit_item" => __( "Edit Reservation", "" ),
);
$args = array(
"label" => __( "Team Rooms", "" ),
"labels" => $labels,
"description" => "",
"public" => false,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"has_archive" => false,
"show_in_menu" => true,
"exclude_from_search" => true,
"capability_type" => "teamrooms",
"capabilities" => array(
"create_posts" => "edit_posts",
"delete_others_posts" => "edit_posts",
"delete_post" => "edit_posts",
"delete_posts" => "edit_posts",
"delete_private_posts" => "edit_posts",
"delete_published_posts" => "edit_posts",
"edit_others_posts" => "edit_posts",
"edit_post" => "edit_posts",
"edit_posts" => "edit_posts",
"edit_published_posts" => "edit_posts",
"publish_posts" => "edit_posts",
"read" => "read",
"read_post" => "read",
"read_posts" => "read",
"read_private_posts" => "edit_posts",
),
//"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => false,
"query_var" => true,
"menu_position" => 6,
"menu_icon" => "dashicons-groups",
"supports" => array( "title", "author" ),
);
register_post_type( "teamrooms", $args );
}
add_action( 'init', 'tscpl_register_teamrooms_cpt' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.