-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle user nicename change #3725
base: trunk
Are you sure you want to change the base?
Conversation
Just found an edge case. If the term slug we want to rename the term to already exists, the script will fail to change the term slug and the posts will no longer be assigned to the user. This will only happen in a broken database... but that's the kind of database where we want to use this tool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as described!
Sorry @dkoo . I removed the Needs review label because I wanted to make some adjustments... I added it back again now. The CLI will now check the availability of the nicename, including looking for CAP terms, before doing anything. WP will already do it for the nicename itself, and add a suffix to avoid conflict, but it ignores the CAP terms... so I added this check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-tested and it still works! Good call on adding the checks for preexisting nicenames.
All Submissions:
Changes proposed in this Pull Request:
This PR adds some special handling to allow for a safe change of a user's nicename.
User nicename is used to build the user author archive URL, and it's also what CoAuthors Plus use to create the taxonomy that handles posts authorship.
With this PR, when a user_nicename changes:
author
)How to test the changes in this Pull Request:
wp newspack nicename-change <user_id> <new_nicename>
Test check nicename
wp newspack nicename-check <nicename>
with a username you know is in use and confirm you see the appropriate outputcap-joe
exists, runwp newspack nicename-check joe
andwp newspack nicename-check cap-joe
.Other information: