Skip to content
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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

leogermani
Copy link
Contributor

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

@leogermani leogermani self-assigned this Aug 24, 2023
Copy link
Member

@naxoc naxoc left a 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 ) {
Copy link
Member

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();
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@naxoc naxoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants