Skip to content

Commit

Permalink
fix(co-authors-plus): CLI for migrating from CAP GA
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Oct 28, 2024
1 parent e089172 commit 9a81584
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions includes/cli/class-co-authors-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function backfill_non_editing_contributor( $args, $assoc_args ) {
$users = get_users(
[
'role__in' => [ 'subscriber', 'customer' ],
'role__not_in' => [ \Newspack\Co_Authors_Plus::CONTRIBUTOR_NO_EDIT_ROLE_NAME, 'administrator', 'editor', 'author', 'contributor' ],
'role__not_in' => [ \Newspack\Guest_Contributor_Role::CONTRIBUTOR_NO_EDIT_ROLE_NAME, 'administrator', 'editor', 'author', 'contributor' ],
'fields' => 'ID',
'number' => -1,
]
Expand All @@ -170,7 +170,7 @@ public function backfill_non_editing_contributor( $args, $assoc_args ) {
if ( count_user_posts( $user_id ) > 0 ) { // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.count_user_posts_count_user_posts
if ( self::$live ) {
WP_CLI::line( sprintf( 'Will add the Non-Editing Contributor role to user %d.', $user_id ) );
get_user_by( 'id', $user_id )->add_role( \Newspack\Co_Authors_Plus::CONTRIBUTOR_NO_EDIT_ROLE_NAME );
get_user_by( 'id', $user_id )->add_role( \Newspack\Guest_Contributor_Role::CONTRIBUTOR_NO_EDIT_ROLE_NAME );
} else {
WP_CLI::line( sprintf( 'Would add the Non-Editing Contributor role to user %d.', $user_id ) );
}
Expand Down Expand Up @@ -266,7 +266,7 @@ function( $value ) {
'user_nicename' => isset( $post_meta['cap-user_login'] ) ? $post_meta['cap-user_login'] : '',
'user_url' => isset( $post_meta['cap-website'] ) ? $post_meta['cap-website'] : '',
'user_pass' => wp_generate_password(),
'role' => \Newspack\Co_Authors_Plus::CONTRIBUTOR_NO_EDIT_ROLE_NAME,
'role' => \Newspack\Guest_Contributor_Role::CONTRIBUTOR_NO_EDIT_ROLE_NAME,
'display_name' => isset( $post_meta['cap-display_name'] ) ? $post_meta['cap-display_name'] : '',
'first_name' => isset( $post_meta['cap-first_name'] ) ? $post_meta['cap-first_name'] : '',
'last_name' => isset( $post_meta['cap-last_name'] ) ? $post_meta['cap-last_name'] : '',
Expand Down Expand Up @@ -420,7 +420,7 @@ private static function migrate_linked_guest_authors() {
self::assign_user_meta( $guest_author, $user_id );

// Add the Non-Editing Contributor role.
$linked_user->add_role( \Newspack\Co_Authors_Plus::CONTRIBUTOR_NO_EDIT_ROLE_NAME );
$linked_user->add_role( \Newspack\Guest_Contributor_Role::CONTRIBUTOR_NO_EDIT_ROLE_NAME );
}
}

Expand Down

0 comments on commit 9a81584

Please sign in to comment.