Skip to content

Instantly share code, notes, and snippets.

@jgalea
Last active May 15, 2020 02:01
Show Gist options
  • Save jgalea/5983652 to your computer and use it in GitHub Desktop.
Save jgalea/5983652 to your computer and use it in GitHub Desktop.
Creating a new post type with capabilities.
<?php
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type(
'movie',
array(
'public' => true,
'capability_type' => 'movie',
'capabilities' => array(
'publish_posts' => 'publish_movies',
'edit_posts' => 'edit_movies',
'edit_others_posts' => 'edit_others_movies',
'read_private_posts' => 'read_private_movies',
'edit_post' => 'edit_movie',
'delete_post' => 'delete_movie',
'read_post' => 'read_movie',
),
)
);
}
@csaborio001
Copy link

When you create a post type and assign it custom capabilities, you have to assign those capabilities to users or roles. By default these capabilities are not assigned to any roles or users, hence you don't see them, even though they exist.

Use a plugin like Members to view the capability to find MOVIE and give yourself access to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment