Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
287 stars 205 forks source link

Migrating from custom system, and not able to keep the order in authors. Wrong sorting. #1052

Open manuelRod opened 3 weeks ago

manuelRod commented 3 weeks ago

Hello,

We are currently migrating from another custom system to co-authors. We are having a lot of trouble with the migration since the ordering of authors seems to be completely random. Sometimes (most of the time) respects the old order, but sometimes it doesn't. Maybe the way we are doing it it's wrong (?)

How are we doing it? Passing an array of authors (with user_nicename) to add_coauthors function.

global $coauthors_plus;
$new_co_authors = [ 'Jhon Doe', 'Test User'];
$coauthors_plus->add_coauthors( $post_id, array_map( 'sanitize_title', $new_co_authors ) );

Sometimes we will get co-authors in the right other, sometimes inverse.

Why the order is sometimes not respected? I tried other combinations, like calling add_coauthors with just one author, n times. Nothing seems to work, and all the time seems random.

Any clues? Are we doing it wrong?

Thanks,

bystrzan commented 3 weeks ago

Regular posts also doesn't respect the sorting option from post editing screen (gutenberg + hybrid theme)

manuelRod commented 3 weeks ago

@bystrzan While I was debugging this issue, I noticed that the AJAX call made in the post editor also uses add_coauthors. Meaning, as you mentioned, sometimes the order won't be respected also using the plugin itself.

eddiesshop commented 6 days ago

@manuelRod by any chance, do you still see the same thing happening if you used this PR?