Filter for limiting the terms created for users
-
One of our client sites has several thousand user accounts in their database. All but a few of these are Subscribers, not Authors/Editors/etc.
When trying to add a co-author to a post and searching for something like “Dave”, the “$found_terms = get_terms( $this->coauthor_taxonomy, $args );” call returns the first 10 matches, and if the guest author or real author user is not in this list, nothing is returned to the frontend due to the ‘edit_posts’ check a bit farther down in the function.
I believe the main issue is the update_author_term() doesn’t have a check to see if the real user has the ‘edit_posts’ capability before creating the term. We don’t need several thousand terms in the database for Subscriber roles, just the roles that can edit posts. Adding something like “has_cap( apply_filters( ‘coauthors_edit_author_cap’, ‘edit_posts’ ) )” before inserting the term should solve this issue.
In the meantime, we’re using the ‘coauthors_search_authors_get_terms_args’ filter to increase the number of matches from the term search to get enough data for the code farther down in the function.
Example screenshot of the terms returned searching for “Dave”, but none of these user accounts have any access to edit posts, all are Subscribers.
- The topic ‘Filter for limiting the terms created for users’ is closed to new replies.