Created
June 1, 2010 12:10
-
-
Save thenbrent/420859 to your computer and use it in GitHub Desktop.
Custom post type caps experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Custom Post Type Capabiltiies Test | |
Plugin URI: http://wordpress.org/ | |
Description: Testing to see if a subscriber without edit_others capability can edit posts. | |
Author: Brent | |
Version: 1 | |
*/ | |
function ppt_register_post_type() { | |
$role = get_role( 'subscriber' ); | |
$add = true; | |
if( $add ){ | |
$role->add_cap( 'publish_movies' ); | |
$role->add_cap( 'edit_movie' ); | |
$role->add_cap( 'edit_movies' ); | |
//$role->add_cap( 'edit_others_movies' ); | |
//$role->add_cap( 'read_private_movies' ); | |
//$role->add_cap( 'delete_movie' ); | |
} | |
if( !$add ){ | |
$role->remove_cap( 'publish_movies' ); | |
$role->remove_cap( 'edit_movie' ); | |
$role->remove_cap( 'edit_movies' ); | |
$role->remove_cap( 'edit_others_movies' ); | |
$role->remove_cap( 'read_private_movies' ); | |
$role->remove_cap( 'delete_movie' ); | |
} | |
register_post_type( 'movie', array( | |
'label' => 'Movies', | |
'labels' => array( 'singular_name' => 'Movie' ), | |
'public' => TRUE, | |
'query_var' => TRUE, | |
'rewrite' => TRUE, | |
'capability_type' => 'movie' | |
) | |
); | |
error_log('$role = ' . print_r( $role, true ) ); | |
} | |
add_action( 'init', 'ppt_register_post_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment