Automattic / Automattic/co-authors-plus
Filter Ajax Suggested Authors
- Dominant language
- PHP
- Stars
- 322
- Forks
- 216
- Avg merge
- 7h 50m
- Merged PRs (30d)
- 65
Description
Due to the requirements of a project that I am working on, the authors need to be filtered in a more complex manner than `coauthors_search_authors_get_terms_args` can offer.
While `coauthors_edit_ignored_authors` would not be feasible to add 100,000s of user ids.
The requirement is to both check the logged-in user's meta and role, and then the coauthors. This would be easily achieved with a filter within the coauthors plugin either as below in the `search_authors` method or within the `ajax_suggest` method.
In respect to version 3.4.8
In file `co-authors-plus.php` for method `search_authors()` and before the return statement `return (array) $found_users;`
Adding a final filter for the returned coauthors.
Something like;
```
/**
* Filter: coauthors_search_authors_found_users
* Filters the found users array. Allowing for final additional checks such as current
* logged-in user, meta, roles, and capabilities in comparison to those of the found users.
*
* @param array $found_users The found authors.
*/
$found_users = apply_filters( 'coauthors_search_authors_found_users', $found_users );
```
Contributor guide
Research direction
Read co-authors-plus.php and locate search_authors(), especially the return of $found_users; compare it with the existing coauthors_search_authors_get_terms_args filter. Done means a documented filter can make final checks against the current user and found authors before the results are returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100