First I will explain the scenario, I want to make a system where you will have 4 different types of people accessing.
The Administrator, "moderators", authors, and partners.
I wanted to use the wordpress admin panel for everything, so I created a post_type
partner. In this system, each partner can have a page on the site. And also, use the standard blog (blog) system of wordpress.
So to manage all of this I thought about changing the existing roles
to be organized this way:
ROLES:
ADMIN -
all
Editor -
Pode Cadastrar novo post
Ver todos os posts de qualquer autor
Editar o post de qualquer autor
Publicar posts e deixar para revisão pendente
Cadastrar página de parceiro
Ver todas as páginas de parceiros
Editar as páginas de parceiros de qualquer autor
Publicar página de parceiro e deixar para revisão pendente
Autor -
Pode cadastrar novo post
ver apenas seus proprios posts
editar apenas seus proprios posts
não pode publicar (sempre lançar como revisão)
Colaborador -
Ver apenas as suas página de parceiro
Editar apenas sua página de parceiro
Não pode publicar página de parceiro (sempre lançar como revisão)
Subscriber -
Nada!
So the question has arisen, is this the best way to organize it? Or it would be better to create new roles (at least to manage the partners).
And besides, now technical doubts, to create capabilities
new in a custom post_type
, would be passing the capabilities
argument in this way:
'capabilities' => array(
'edit_post' => 'edit_partner',
'edit_posts' => 'edit_partners',
'edit_others_posts' => 'edit_other_partners',
'publish_posts' => 'publish_partners',
'read_post' => 'read_partner',
'read_private_posts' => 'read_private_partners',
'delete_post' => 'delete_partner'
)
And then add in each role:
$admins = get_role( 'administrator' );
$admins->add_cap( 'edit_post' );
$admins->add_cap( 'edit_posts' );
$admins->add_cap( 'edit_others_posts' );
$admins->add_cap( 'publish_posts' );
$admins->add_cap( 'read_post' );
$admins->add_cap( 'read_private_posts' );
$admins->add_cap( 'delete_post' );
$editors = get_role( 'editor' );
$editors->add_cap( 'edit_post' );
$editors->add_cap( 'edit_posts' );
$editors->add_cap( 'edit_others_posts' );
$editors->add_cap( 'publish_posts' );
$editors->add_cap( 'read_post' );
$editors->add_cap( 'read_private_posts' );
$editors->add_cap( 'delete_post' );
$partners = get_role( 'subscriber' );
$partners->add_cap( 'edit_post' );
I tried exactly as I showed above, but it did not register the custom post_type with the argument capabilities
.
In short:
I do not know if it's right to tweak% s of%% of% wordpress patterns, and not even how to do that
And I also do not know how to give permission for only capabilities
, I did not want roles
users to view / change / edit normal posts, only custom post_type
, and yet, only the link to his user. And even if Colaboradores
users could view / edit / change post_type parceiro
.
Thank you.