Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anilmeena/0e6bc68563f5f0234fdcb870f7e62471 to your computer and use it in GitHub Desktop.
Save anilmeena/0e6bc68563f5f0234fdcb870f7e62471 to your computer and use it in GitHub Desktop.
Add Capabilities for Custom Post type
<?php
// Add Capabilities for Custom Post type
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',
),
)
);
}
// Then add all these capabilities from User Role Editor Plugins setting page.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment