douxia1988 2015-04-10 08:20
浏览 39

Wordpress - 自定义角色问题。 无法查看自定义帖子类型的仪表板列表

  1. I have a custom post type named - Event
  2. I have a custom role named coordinator and another custom role named agent
  3. I want coordinators to be able to fully manage Events from admin area dashboard while agents to not.
  4. I managed to do this fine so far: a. Events link under plugin menu displays fine to Coordinators. b. Events link under plugin menu doesn't display to Agents. c. Events link under plugin menu doesn't display to Administrator. d. Administrators can add/edit/delete Events fine from admin area.

But When a coordinator clicks on the Events link in admin dashboard under plugin menu, it displays "You do not have sufficient permissions to access this page.".

But If I give a direct URL to browser logged in as an coordinator to edit an event with post_id in Querystring, it works fine. So somehow, a coordintator is not able to list all the events as a dashboard post listing page.

Thats how I created custom post type and its capabilities under register_post_type

'capability_type' => 'event',
'capabilities' => array(
    'publish_posts' => 'publish_events',
                    'edit_posts' => 'edit_events',
                    'edit_others_posts' => 'edit_others_events',
                    'delete_posts' => 'delete_events',
                    'delete_others_posts' => 'delete_others_events',
                    'read_private_posts' => 'read_private_events',
                    'edit_post' => 'edit_event',
                    'read_post' => 'read_event',
                    'delete_post' => 'delete_event',
                    'publish_post' => 'publish_event',   
    ),
    //'map_meta_cap' => true,                
)

And this is how capabilities are added to the role (This is done under plugin's activation hook because I think this gets added to database so no need to run this code on every page execution. Please correct if am wrong)

$role = get_role( 'coordinator' );
$role->add_cap( 'read' );            
$role->add_cap( 'edit_posts' );          
$role->add_cap( 'edit_others_posts' );                       
$role->add_cap( 'edit_event' ); 
$role->add_cap( 'edit_events' ); 
$role->add_cap( 'edit_others_events' ); 
$role->add_cap( 'publish_events' ); 
$role->add_cap( 'read_event' ); 
$role->add_cap( 'read_private_events' ); 
$role->add_cap( 'delete_event' );            
$role->add_cap( 'delete_events' );           
$role->add_cap( 'delete_others_events' ); 

Please assist. Thanks for assistance in advance.

Regards

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码