Following usecase:
Post A is assigned to author X (main author) and author Y (co-author).
Deleting author Y, no form for replacing the author in posts is shown, per wordpress default.
Deleting author X, the form is shown and I can select author Z to be set as the new author for post A.
Expected behaviour:
Deleting author X, post A should have author Z as main author and author Y remains as co-author.
Actual behaviour:
Deleting author X, post A has author Z as main author but author Y vanishes from the list of authors.
I dug through the code and found CoAuthors_Plus::add_coauthors(). In line 861, $existing_coauthors holds the user_login, in line 868, another reference to user_login is made.
In line 876, while iterating over the user_login strings, get_coauthor_by('user_nicename', $author_name) searches the user_nicename with having the user_login in $author_name. user_nicename and user_login are different in the above use case and false is returned.
Therefore, in line 881 wp_set_post_terms() removes all authors from the post.
When I change lines 868 and 876 to user_nicename instead of user_login, deleting a main author produces the expected behaviour.
Is this a bug or did I not understand the feature correctly?
Hi,
Following usecase: Post A is assigned to author X (main author) and author Y (co-author).
Deleting author Y, no form for replacing the author in posts is shown, per wordpress default. Deleting author X, the form is shown and I can select author Z to be set as the new author for post A.
Expected behaviour: Deleting author X, post A should have author Z as main author and author Y remains as co-author.
Actual behaviour: Deleting author X, post A has author Z as main author but author Y vanishes from the list of authors.
I dug through the code and found
CoAuthors_Plus::add_coauthors()
. In line 861, $existing_coauthors holds the user_login, in line 868, another reference to user_login is made. In line 876, while iterating over the user_login strings,get_coauthor_by('user_nicename', $author_name)
searches the user_nicename with having the user_login in $author_name. user_nicename and user_login are different in the above use case and false is returned. Therefore, in line 881 wp_set_post_terms() removes all authors from the post.When I change lines 868 and 876 to user_nicename instead of user_login, deleting a main author produces the expected behaviour.
Is this a bug or did I not understand the feature correctly?