Recently, I needed to make my Facebook Tabs closed to my client. However, the plugin didn't do this, so digging into it, there was one minor change that needed to be made regarding capabilities and capability_type. For a reference, view Justin Tadlock's post, Meta capabilities for custom post types.
Since I use the Members plugin to help me with role management, I only had to make one minor change in the custom post type registration code. Around line 270, fbtab.php registers the Facebook Tab custom post type. To add capabilities and the capability_type delete the create_fbtab_post_type function and use this function instead.
[php]<?php
function create_fbtab_post_type() {
register_post_type( 'fbtab',
array(
'labels' => array(
'name' => __( 'Facebook Tabs' ),
'add_new_item' => __( 'Add New Facebook Tab' ),
'edit_item' => __( 'Edit Facebook Tab' ),
'new_item' => __( 'Facebook Tabs' ),
'singular_name' => __( 'Facebook Tab' )
),
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'fbtabs',
'capabilities' => array(
'publish_posts' => 'publish_fbtabs',
'edit_posts' => 'edit_fbtabs',
'edit_others_posts' => 'edit_others_fbtabs',
'delete_posts' => 'delete_fbtabs',
'delete_others_posts' => 'delete_others_fbtabs',
'read_private_posts' => 'read_private_fbtabs',
'edit_post' => 'edit_fbtabs',
'delete_post' => 'delete_fbtabs',
'read_post' => 'read_fbtabs',
),
'hierarchical' => true,
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => plugins_url('/facebook.png',__FILE__),
'supports' => array('title','editor')
)
);
}
[/php]
Then I went into my Members plugin role management, created some capabilities based on the capabilities array. Then I locked out certain individuals. Wha la! For those who prefer the code to do this, please refer to Justin Tadlock's post, Meta capabilities for custom post types. It is "most excellent"! (I think I just dated myself!)
Leave a Reply