我正在创建一个名为“销售”的新角色,我在其中添加了功能,因此销售人员只能在管理面板中阅读、编辑和删除潜在客户。
一切正常,只是我不能选择多个潜在客户(帖子)并一次删除它们。我添加了“delete\\u lead”和“delete\\u lead”功能,因此我认为这应该是可行的。
// Create sales role
add_role( \'sales\', __( \'Sales\', \'gtp_translate\' ) );
// Add sales capabilities to sales
$roles = array( \'sales\', \'editor\', \'administrator\' );
foreach( $roles as $the_role ) {
// Get role object by role name
$role = get_role( $the_role );
// Add capabilities to this role
$role->add_cap( \'edit_lead\' );
$role->add_cap( \'read_lead\' );
$role->add_cap( \'delete_lead\' );
$role->add_cap( \'edit_others_leads\' );
$role->add_cap( \'publish_leads\' );
$role->add_cap( \'edit_leads\' );
$role->add_cap( \'read_private_leads\' );
$role->add_cap( \'delete_leads\' );
$role->add_cap( \'delete_private_leads\' );
$role->add_cap( \'delete_published_leads\' );
$role->add_cap( \'delete_others_leads\' );
$role->add_cap( \'edit_private_leads\' );
$role->add_cap( \'edit_published_leads\' );
}
通常情况下,您的帖子类型操作下拉列表应该与图像相似,但“移至垃圾箱”现在不存在。
My Leads custom post type
// Leads
$labels = array(
\'name\' => _x( \'Leads\', \'Post Type General Name\', \'gtp_translate\' ),
\'singular_name\' => _x( \'Lead\', \'Post Type Singular Name\', \'gtp_translate\' ),
\'menu_name\' => __( \'Leads\', \'gtp_translate\' ),
\'parent_item_colon\' => __( \'Parent Lead:\', \'gtp_translate\' ),
\'all_items\' => __( \'All Leads\', \'gtp_translate\' ),
\'view_item\' => __( \'View Lead\', \'gtp_translate\' ),
\'add_new_item\' => __( \'Add New Lead\', \'gtp_translate\' ),
\'add_new\' => __( \'Add New\', \'gtp_translate\' ),
\'edit_item\' => __( \'Edit Lead\', \'gtp_translate\' ),
\'update_item\' => __( \'Update Lead\', \'gtp_translate\' ),
\'search_items\' => __( \'Search Leads\', \'gtp_translate\' ),
\'not_found\' => __( \'Not found\', \'gtp_translate\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'gtp_translate\' ),
);
$args = array(
\'label\' => \'leads\',
\'description\' => \'Leads\',
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'author\', \'revisions\', \'custom-fields\', ),
\'hierarchical\' => false,
\'public\' => false,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => false,
\'show_in_admin_bar\' => true,
\'menu_position\' => 3,
\'menu_icon\' => \'\',
\'can_export\' => true,
\'has_archive\' => false,
\'exclude_from_search\' => true,
\'publicly_queryable\' => false,
\'capability_type\' => array( \'lead\', \'leads\' ),
);
register_post_type( \'leads\', $args );