3
First I’ll explain the scenario, I want to make a system where there will be four different types of people accessing it.
The Administrator, "moderators", authors, and partners.
I wanted to use the wordpress admin panel itself 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 default wordpress posts (blog) system.
So to manage all this I thought I’d change the roles
existing to be organized in 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!
When the doubt arose, is this the best way to organize it? Or would it 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 argument capabilities
in that 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 roll:
$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' );
Because I tried exactly as shown above, but he did not register the custom post_type with the argument capabilities
.
To summarize:
I don’t know if it’s right to touch capabilities
of roles
wordpress patterns, and not exactly how to do it
And I also don’t know how to give permission only to one custom post_type
, I didn’t want the users Colaboradores
could see/change/edit normal posts, only the post_type parceiro
, and yet, only the link to the user of it. And nor that users Autores
can see/edit/change the post_type parceiro
.
Thank you.