Bug in coauthors_plus->search_authors()
I think I've pinpointed a bug in co-authors search_authors. We were having issues assigning some posts to some authors when creating a post.
Look at the following block of code:
foreach( $found_terms as $found_term ) {
$found_user = $this->get_coauthor_by( 'user_nicename', $found_term->slug );
if ( !empty( $found_user ) )
$found_users[$found_user->user_login] = $found_user;
}
get_coauthor_by() function uses wordpress function get_user_by to get user data. However it's passing the term's slug as second argument instead of user's nicename.
Some more information:
When updating term's slug cap- is prefixed to user's nicename. And when it's passed to get_coauthor_by(), 'cap-' is removed and the search is performed. So far, so good. However, if the user's nicename contain spaces, they get replaced by dashes. So that's the real issue.
Some update. I replaced spaces in display_name and user_nicename directly from the database for one of my authors and his name started appearing in the drop down and I was able to assign him to a post as author.
Hi @dpacmittal,
Are you still experiencing this issue? If so, can you give me better steps on how to reproduce the issue you are having? I'm not sure why your user_nicename has spaces in it because spaces are typically sanitized from that field.