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: add command to link all users to GAs #331
base: trunk
Are you sure you want to change the base?
Conversation
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.
I added a couple of small stuff comments, but this is a great addition. Thanks!
* @param string $file File name or path. | ||
* @param string $message Log message. | ||
*/ | ||
public function log( $file, $message ) { |
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.
It looks like the Logger instance is used instead of this one. Can it be deleted?
$guest_authors = new \CoAuthors_Guest_Authors(); | ||
|
||
// Get the list of users. | ||
$users = get_users(); |
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.
I could worry that on a large site with many users this would be a heavy query. If we only need the ID – we could maybe use a raw query for them instead?
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.
We actually only need the user_email, but link_guest_author_to_wp_user
takes the WP_User object as a parameter
We could just add the post_meta ourselves... or we could just get the user if needed to pass to that function.
However, if I refactored that now I would not be able to test it in a good way... I think I rather stick with the tested code for now and address this if it becomes an issue in a future migration
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.
Looks good! 👍
Adds a new command to the CoAuthorsPlus migrator class
It will loop through all WP users and look for a Guest Author with the same email.
If the guest author is not already linked to an account, it will link the guest author to that account.
Tested on NewsroomNZ already