我有一个自定义用户角色,称为 form_editor。我希望此用户只能编辑联系表 7。
这是我目前的情况
$form_editor_role = add_role(
'form_editor',
__( 'Form Editor' ),
array(
'read' => true, // true allows this capability
'edit_posts' => true,
'delete_posts' => false, // Use false to explicitly deny
)
);
$role = get_role( 'form_editor' );
if(!$role->has_cap('cfdb7_access')){
$role->add_cap( 'cfdb7_access' );
}
是的,它没有访问帖子的权限。它可以查看联系表,但没有编辑权限。
最佳答案
尝试添加 publish_pages
并添加 remove_role('form_editor');
刷新当前角色
remove_role('form_editor');
add_role('form_editor', __('Form Editor'), array(
'read' => true, // true allows this capability
'edit_posts' => true,
'delete_posts' => false, // Use false to explicitly deny
'publish_pages' => true
));
$role = get_role('form_editor');
if (!$role->has_cap('cfdb7_access')) {
role->add_cap('cfdb7_access');
}
关于php - Wordpress 用户角色仅允许访问 Contact Form 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52966570/