我制作了一些自定义帖子类型和一些用户角色。每个角色都可以访问不同的自定义帖子类型。
问题是edit\\u others\\u customposttypecapability不起作用。我尝试使用管理员帐户登录,但它无法编辑其他人发布的自定义帖子类型。
我已经安装了用户角色编辑器插件,检查了每个用户的功能,管理员应该能够编辑所有站点的帖子。
以下是用户角色。。。
<?php
/*
This page loads all user roles that are necesary to the correct administration of the site.
*/
add_action(\'init\', \'create_metaroles\');
function create_metaroles() {
// Defino los roles
$roles = array();
$roles[\'Webmaster\'] = array(
\'role\' => \'webmaster\',
\'caps\' => array(
array(\'pb_institucional\',\'pb_institucionales\'),
array(\'pb_experto\',\'pb_expertos\'),
array(\'pb_comite\',\'pb_comites\'),
array(\'pb_reunion\',\'pb_reuniones\'),
array(\'pb_progproy\',\'pb_progproys\'),
array(\'pb_vacante\',\'pb_vacantes\'),
array(\'pb_pais\',\'pb_paises\'),
array(\'pb_organizacion\',\'pb_organizaciones\'),
array(\'pb_evento\',\'pb_eventos\'),
array(\'pb_noticia\',\'pb_noticias\'),
array(\'pb_publicacion\',\'pb_publicaciones\'),
array(\'pb_sector\',\'pb_sectores\'),
array(\'pb_producto\',\'pb_productos\'),
array(\'pb_conocimiento\',\'pb_conocimientos\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor Institucional\'] = array(
\'role\' => \'gestor_institucional\',
\'caps\' => array(
array(\'pb_institucional\',\'pb_institucionales\'),
array(\'pb_experto\',\'pb_expertos\'),
array(\'pb_comite\',\'pb_comites\'),
array(\'pb_reunion\',\'pb_reuniones\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Programas y Proyectos\'] = array(
\'role\' => \'gestor_progproy\',
\'caps\' => array(
array(\'pb_progproy\',\'pb_progproys\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de RRHH\'] = array(
\'role\' => \'gestor_rrhh\',
\'caps\' => array(
array(\'pb_vacante\',\'pb_vacantes\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Comunicacion Institucional\'] = array(
\'role\' => \'gestor_comunicacion\',
\'caps\' => array(
array(\'pb_pais\',\'pb_paises\'),
array(\'pb_organizacion\',\'pb_organizaciones\'),
array(\'pb_evento\',\'pb_eventos\'),
array(\'pb_noticia\',\'pb_noticias\'),
array(\'pb_publicacion\',\'pb_publicaciones\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Sectores\'] = array(
\'role\' => \'gestor_sectores\',
\'caps\' => array(
array(\'pb_sector\',\'pb_sectores\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Sectores, Programas y Proyectos\'] = array(
\'role\' => \'gestor_sectores\',
\'caps\' => array(
array(\'pb_sector\',\'pb_sectores\'),
array(\'pb_sector\',\'pb_sectores\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Productos\'] = array(
\'role\' => \'gestor_productos\',
\'caps\' => array(
array(\'pb_producto\',\'pb_productos\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
$roles[\'Gestor de Biblioteca/Conocimiento\'] = array(
\'role\' => \'gestor_conocimiento\',
\'caps\' => array(
array(\'pb_conocimiento\',\'pb_conocimientos\')
),
\'capabilities\' => array(
\'read\' => true,
\'edit_posts\' => true,
\'delete_posts\' => true,
\'publish_posts\' => true,
\'upload_files\' => true
)
);
foreach( $roles as $name => $arr ){
add_role($arr[\'role\'], $name,
array(
\'read\' => true,
\'edit_posts\' => false,
\'delete_posts\' => false,
\'publish_posts\' => false,
\'upload_files\' => true
));
$rol = get_role( $arr[\'role\'] );
foreach( $arr[\'caps\'] as $cap ){
$rol->add_cap( \'read\' );
$rol->add_cap( \'read_\' . $cap[0] );
$rol->add_cap( \'read_private_\' . $cap[1] );
$rol->add_cap( \'edit_\' . $cap[1] );
$rol->add_cap( \'edit_others_\' . $cap[1] );
$rol->add_cap( \'edit_published_\' . $cap[1] );
$rol->add_cap( \'publish_\' . $cap[1] );
$rol->add_cap( \'delete_\' . $cap[0] );
$rol->add_cap( \'delete_others_\' . $cap[1] );
$rol->add_cap( \'delete_private_\' . $cap[1] );
$rol->add_cap( \'delete_published_\' . $cap[1] );
}
$rol = get_role(\'webmaster\');
$rol->add_cap( \'add_users\' );
$rol->add_cap( \'create_users\' );
$rol->add_cap( \'delete_users\' );
$rol->add_cap( \'edit_users\' );
$rol->add_cap( \'list_users\' );
$rol->add_cap( \'promote_users\' );
$rol->add_cap( \'remove_users\' );
$rol->add_cap( \'manage_categories\' );
$rol->add_cap( \'edit_plugins\' );
$rol->add_cap( \'edit_theme_options\' );
$rol->add_cap( \'manage_links\' );
$rol->add_cap( \'manage_options\' );
$rol = get_role( \'administrator\' );
foreach( $arr[\'caps\'] as $cap ){
$rol->add_cap( \'read\' );
$rol->add_cap( \'read_\' . $cap[0] );
$rol->add_cap( \'read_private_\' . $cap[1] );
$rol->add_cap( \'edit_\' . $cap[1] );
$rol->add_cap( \'edit_others_\' . $cap[1] );
$rol->add_cap( \'edit_others_\' . $cap[0] );
$rol->add_cap( \'edit_published_\' . $cap[1] );
$rol->add_cap( \'publish_\' . $cap[1] );
$rol->add_cap( \'delete_\' . $cap[0] );
$rol->add_cap( \'delete_others_\' . $cap[1] );
$rol->add_cap( \'delete_private_\' . $cap[1] );
$rol->add_cap( \'delete_published_\' . $cap[1] );
}
}
}
?>
我只复制一个自定义的post类型声明(我使用15个,但复制所有声明没有意义)
class PB_Noticias {
public function __construct(){
$this->register_post_type();
}
public function register_post_type(){
$labels = array(
\'name\' => __( \'Noticias\', \'text-domain\' ),
\'singular_name\' => __( \'Noticia\', \'text-domain\' ),
\'add_new\' => _x( \'Agregar Noticia\', \'text-domain\', \'text-domain\' ),
\'add_new_item\' => __( \'Agregar Noticia\', \'text-domain\' ),
\'edit_item\' => __( \'Editar Noticia\', \'text-domain\' ),
\'new_item\' => __( \'Nuevo Noticia\', \'text-domain\' ),
\'view_item\' => __( \'Ver Noticia\', \'text-domain\' ),
\'search_items\' => __( \'Buscar Noticias\', \'text-domain\' ),
\'not_found\' => __( \'No se encontraron Noticias\', \'text-domain\' ),
\'not_found_in_trash\' => __( \'No se encontraron Noticias en la papelera\', \'text-domain\' ),
\'parent_item_colon\' => __( \'Noticia Padre:\', \'text-domain\' ),
\'menu_name\' => __( \'Noticias\', \'text-domain\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'description\' => \'Noticias OLADE\',
\'taxonomies\' => array(\'category\', \'post_tag\'),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 30,
\'menu_icon\' => admin_url() . \'images/project.png\',
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => \'noticias\',
\'can_export\' => true,
\'rewrite\' => array(
\'slug\' => \'noticias\'
),
\'capability_type\' => array(\'pb_noticia\',\'pb_noticias\'),
\'supports\' => array(
\'title\', \'editor\'
)
);
register_post_type(\'pb_noticia\', $args );
}
// Galeria
// Foto grande
// Cuerpo de la nota
}
知道为什么edit\\u others\\u cpt不起作用吗?
提前感谢!