Updated delete_user_action function to fix issues #268 and #312 #313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've updated the delete_user_action to correct two issues (#268 and #312).
To fix #268 I've pulled the coauthor_term to utilize it's term_id in the wp_delete_term so as to properly delete the author term. Previously was using the user_login which does nothing. To reproduce the original issue you can delete a coauthor through the user_delete mechanism, then if you add a user with the exact same username they'll show up again on the post as a coauthor. This fix fully removes the relation to the post.
To fix #312 I've updated the posts lookup from the broken sql statement to a get_posts using the tax_query. Previously delete user would only reassign if the deleted user was the primary author as they'd be set as post_author, any secondary authors were overlooked. Now by using the get_posts and tax_query we cover all bases and properly reassign ALL posts/cpt/etc. to the reassign user.
Thoughts/Feedback? Happy to discuss.
Cheers