Skip to content

Instantly share code, notes, and snippets.

@dnavarrojr
Created April 30, 2018 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnavarrojr/245e0c032e0a10dd619c3c29ac294f9e to your computer and use it in GitHub Desktop.
Save dnavarrojr/245e0c032e0a10dd619c3c29ac294f9e to your computer and use it in GitHub Desktop.
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