0

Is there a filter to modify the presentation of certain editor editor components? For my example, I want to be able to filter the author list which is a select input in the Gutenberg editor on the document pane.

I know the component I want to modify is located here: https://github.com/WordPress/gutenberg/blob/8517779feddf3de0b86465fae8f21f4384447c58/packages/editor/src/components/post-author/index.js

2
  • Which functionality you want to add? – BenB Sep 7 '19 at 1:44
  • I want to be able to show more properties from the user object than just the pretty name. We have a case where we have multiple username slugs with the same pretty name, and so we need to show both in the select box – Jim Schofield Sep 9 '19 at 0:05
0

The component post-author uses getAuthors() to get the authors, this functions calls the REST API.

export function* getAuthors() {
    const users = yield apiFetch( { path: '/wp/v2/users/?who=authors&per_page=-1' } );
    yield receiveUserQuery( 'authors', users );
}

So you can only filter via the REST API filter rest_user_query, but this can have effects on other plugins which also use this endpoint to get the user list.

1
  • This is good to get the author list, so thank you for that. But I need to then change the author based on this new list. I'm trying to find a hook for that- is there a hook that would allow me to set the author? – Jim Schofield Sep 9 '19 at 0:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.