Co-Authors-Plus icon indicating copy to clipboard operation
Co-Authors-Plus copied to clipboard

Bug in coauthors_plus->search_authors()

Open dpacmittal opened this issue 12 years ago • 3 comments

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.

dpacmittal avatar Oct 09 '13 11:10 dpacmittal

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.

dpacmittal avatar Oct 09 '13 12:10 dpacmittal

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.

dpacmittal avatar Oct 10 '13 10:10 dpacmittal

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.

rebeccahum avatar Jun 05 '17 20:06 rebeccahum