非常感谢,最后我这样做是为了更改表单提交上的状态:
wp\\U insert\\U post(团队\\U post);
// Get the member ID
$user_id = get_current_user_id();
// Change his role to Team Admin
wp_update_user([
\'ID\' => $user_id,
\'role\' => \'TeamAdmin\'
]);
我的新角色就是这样
类oArenaRole{公共函数\\uu构造(){
$this->addCap();
}
public function addRole()
{
// Create new role for Admin Team
add_role(\'TeamAdmin\', \'Administrateur de la team\', [
\'read\' => true,
\'edit_published_posts\' => true,
]);
}
public function addCap()
{
$role = get_role(\'Team Admin\');
}
public function removeRole()
{
remove_role(\'TeamAdmin\');
}
public function activation()
{
$this->addRole();
$this->addCap();
}
public function deactivation()
{
$this->removeRole();
}
}
提交时状态更改,但TeamAdmin无法编辑其发布的CPT