admin管理员组文章数量:1392088
I'm trying to modify the user dropdown in the post edit screen to show only (a) the current user and (b) the current author of the post. I can't do this using wp_dropdown_users_args
because the meta box in the block editor gets the list of users via a REST query. (wp_dropdown_users_args
works fine for the user dropdown in the "Quick Edit" form, however.)
rest_user_query
can modify this dropdown for me, but I can't seem to get any info about the post I'm editing, so I'm unable to determine who the current author is. I can add the current user to the include
value, but then the dropdown doesn't appear at all (I assume because it has only returned a single user).
What I want to do is something like this, but I don't know how to define the $POST_AUTHOR
variable here:
function rest_user_filter( $prepared_args, $request = NULL ) {
$args['include'] = [ get_current_user_id() ];
array_push( $args['include'], $POST_AUTHOR;
return $args;
}
add_filter( 'rest_user_query', 'rest_user_filter' );
I'd also only like to do this on the post edit screen, of course, too.
本文标签: hooksrestuserquery can39t access post author in post edit screen
版权声明:本文标题:hooks - `rest_user_query` can't access post author in post edit screen 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744780648a2624690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论