我已經在wordpress和admin中創建了一個自定義帖子類型,我可以用這個做任何事情。但是我想創建一個只能添加,編輯和刪除這個自定義文章類型的東西的「客戶端」角色,所以他不可以發佈一個普通文章,編輯它或刪除它,並且與頁面一樣。Wordpress自定義帖子類型角色
這是我的我的自定義後類型的參數
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array(
'title',
'thumbnail'
),
'capabilities' => array(
'edit_post' => 'edit_portfolio',
'edit_posts' => 'edit_portfolios',
'edit_others_posts' => 'edit_others_portfolios',
'publish_posts' => 'publish_portfolios',
'read_post' => 'read_portfolios',
'read_private_posts' => 'read_private_portfolios',
'delete_post' => 'delete_portfolio',
),
'map_meta_cap' => true,
'menu_icon' => 'dashicons-screenoptions',
'menu_position' => 5,
'show_ui' => true,
'exclude_from_search' => false
);
而這些是我所創建
add_role("client", "Client", array(
'read' => true, // allows this capability, dashboard
'upload_files'=>true, //allows user to upload files
'edit_posts' => false, // denies user to edit their own posts
'edit_pages' => false, // denies user to edit pages
'edit_others_posts' => false, // denies user to edit others posts not just their own
'create_posts' => false, // denies user to create new posts
'manage_categories' => false, // denies user to manage post categories
'publish_posts' => false, // denies the user to publish
'edit_themes' => false, // false denies this capability. User can’t edit your theme
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User can’t update any plugins
'update_core' => false, // user cant perform core updates
'edit_portfolios' => true, // allows editing of the user’s own portfolio
'edit_others_portfolios' => true, // allows the user to edit everyone else’s portfolio
'delete_portfolios' => true, // allows to delete portfolio written by that user
'delete_others_portfolios' => true, // allows to delete portfolio written by other users
'publish_portfolios' => true // allows the user to publish portfolio, otherwise posts stays in draft mode
));
作用
現在的效果是,他們可以看到儀表盤的職位,但不改變或點擊它,不能刪除,當他們發佈消息時,他們最終出現在錯誤屏幕上,他們不應該看到這一點。
在此先感謝
感謝您的快速回復。 當我看着一個插件,我認爲他們有這樣做的正確權利。 所以我想我需要更多的代碼。 – Arne