1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.