admin管理员组文章数量:1316666
I have created a custom post type.
Each author is attributed to a editor group when her/his account is created. This is save on the author's user meta
I created two roles with administrator capabilities, one for each editor group.
I want to allow (or deny) the editors to edit the posts based on their role and on the author's user meta.
Where can I begin?
I have created a custom post type.
Each author is attributed to a editor group when her/his account is created. This is save on the author's user meta
I created two roles with administrator capabilities, one for each editor group.
I want to allow (or deny) the editors to edit the posts based on their role and on the author's user meta.
Where can I begin?
Share Improve this question asked Oct 29, 2020 at 18:48 drilippidrilippi 314 bronze badges1 Answer
Reset to default 0I manage to filter the posts, this seems to be enough for this project
function remove_notallowed_authors( $query ) {
$user = wp_get_current_user();
if ( in_array( 'editor_group_role', (array) $user->roles ) ) {
$user_ids = get_users( [
'role' => 'user_role_that_posted',
'fields' => 'ID'
] );
$query->set( 'author__in', $user_ids );
}
}
add_action( 'pre_get_posts', 'remove_notallowed_authors' );
本文标签: custom post typesConditional editing CPTusing editor39s role and author39s usermeta
版权声明:本文标题:custom post types - Conditional editing CPT - using editor's role and author's usermeta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742006964a2412152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论