Subscriber to post a Custom Post Type
-
I am trying to setup a custom post type that will allow subscribers to submit a “extension” and that is it. The problem is when capabilities are setup like this the subscriber can select other posts to edit:
'edit_post' => 'read', 'edit_posts' => 'read',
If the capabilities are setup like this the subscriber can’t select any:
'edit_post' => 'edit_post', 'edit_posts' => 'read',
And finally, if the capabilities are setup like this the subscriber can not view the index table for the custom post type:
'edit_post' => 'read', 'edit_posts' => 'edit_posts',
Either I need a way to setup the capabilities so that the subscriber can view the index and edit only their own post or a way to filter the title edit options on the index page. Can anyone help?
/* Plugin Name: WPDI Command Center Plugin URI: Description: Author: Lucas Keiser Version: 0.1-beta Author URI: https://www.keisermedia.com/ Copyright 2010 Lucas Keiser (email : [email protected]) */ class WPDI_Command_Center{ function __construct(){ add_action('init', array(&$this, 'extension_register')); add_action('admin_init', array(&$this, 'admin_init')); add_action('manage_edit-extension_columns', array(&$this, 'extension_edit_columns')); add_action('manage_posts_custom_column', array(&$this, 'extension_custom_columns')); $current_page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1, -4); if( $current_page == 'page' || $current_page == 'page-new' || $current_page == 'post' || $current_page == 'post-new' ){ add_action('admin_head', array(&$this, 'add_post_enctype')); } } function extension_edit_columns($columns){ $columns = array( 'cb' => '<input type="checkbox" />', 'id' => __('ID'), 'title' => __('Extension Title', 'wpdi-cc'), ); return $columns; } function extension_custom_columns($column){ global $post; echo '<pre>'; print $column; echo '</pre>'; if( current_user_can('edit_extension', $post->ID) ){ switch( $column ){ case 'id': break; case 'title': break; } } } function add_post_enctype() { echo ' <script type="text/javascript"> jQuery(document).ready(function(){ jQuery("#post").attr("enctype", "multipart/form-data"); jQuery("#post").attr("encoding", "multipart/form-data"); }); </script>'; } function extension_register(){ global $wp_roles; $labels = array( 'name' => _x('Extensions', 'post type general name'), 'singular_name' => _x('Extension', 'post type singular name'), 'add_new_item' => __('Add New Extension'), 'edit_item' => __('Edit Extension'), 'new_item' => __('New Extension'), 'view_item' => __('View Extension'), 'search_items' => __('Search Extensions'), 'not_found' => __('No extensions found'), 'not_found_in_trash' => __('No extensions foound in Trash'), ); $args = array( 'labels' => $labels, 'public' => true, 'publically_queryable' => true, 'show_ui' => true, 'capability_type' => 'post', 'capabilities' => array( 'edit_post' => 'read', 'edit_posts' => 'read', 'edit_others_posts' => 'edit_others_posts', 'publish_posts' => 'publish_posts', 'read_post' => 'read_post', 'read_private_posts' => 'read_private_posts', 'delete_post' => 'delete_post', ), 'query_var' => true, 'rewrite' => true, 'heirarcical' => false, 'menu_position' => false, 'supports' => array( 'title', ), ); register_post_type('extension', $args); } function admin_init(){ if( current_user_can('edit_others_posts') ){ add_meta_box('extension_meta', 'Extension Information', array(&$this, 'extension_meta'), 'extension', 'normal', 'high'); } } function extension_meta(){ global $post; $custom = get_post_custom($post->ID); $download_url = ( isset($custom['download_url'][0]) ) ? $custom['download_url'][0] : 'https://'; ?> <p><?php _e('In order for our team to evaluate your extension, we must have access by either a direct download or through user submittion.', 'wpdi-cc'); ?></p> <p> <strong><label><?php _e('Direct Download URL', 'wpdi-cc'); ?></label></strong><br /> <input type="text" id="download_url" name="download_url" class="code" style="width: 99%;" value="<?php echo $download_url; ?>" /> </p> <? } function extension_save(){ global $post; update_post_meta($post->ID, 'download_url', $_POST['download_url']); } } $wpdi = new WPDI_Command_Center();
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Subscriber to post a Custom Post Type’ is closed to new replies.