diff --git a/admin/section/class-convertkit-admin-settings-broadcasts.php b/admin/section/class-convertkit-admin-settings-broadcasts.php
index 9eb31ea49..99ef634f3 100644
--- a/admin/section/class-convertkit-admin-settings-broadcasts.php
+++ b/admin/section/class-convertkit-admin-settings-broadcasts.php
@@ -209,6 +209,19 @@ public function register_fields() {
)
);
+ add_settings_field(
+ 'author_id',
+ __( 'Author', 'convertkit' ),
+ array( $this, 'author_id_callback' ),
+ $this->settings_key,
+ $this->name,
+ array(
+ 'name' => 'author_id',
+ 'label_for' => 'author_id',
+ 'description' => __( 'The WordPress User to set as the author for WordPress Posts created from imported broadcasts.', 'convertkit' ),
+ )
+ );
+
add_settings_field(
'category_id',
__( 'Category', 'convertkit' ),
@@ -358,6 +371,32 @@ public function post_status_callback( $args ) {
}
+ /**
+ * Renders the input for the author setting.
+ *
+ * @since 2.3.9
+ *
+ * @param array $args Setting field arguments (name,description).
+ */
+ public function author_id_callback( $args ) {
+
+ // Build field.
+ $select_field = wp_dropdown_users(
+ array(
+ 'echo' => false,
+ 'selected' => $this->settings->author_id(),
+ 'include_selected' => true,
+ 'name' => $this->settings_key . '[' . $args['name'] . ']',
+ 'id' => $this->settings_key . '_' . $args['name'],
+ 'class' => 'enabled convertkit-select2',
+ )
+ );
+
+ // Output field.
+ echo '
' . $select_field . '
' . $this->get_description( $args['description'] ); // phpcs:ignore WordPress.Security.EscapeOutput
+
+ }
+
/**
* Renders the input for the category setting.
*
diff --git a/tests/_support/Helper/Acceptance/Plugin.php b/tests/_support/Helper/Acceptance/Plugin.php
index 17c85847b..8e52d7e2c 100644
--- a/tests/_support/Helper/Acceptance/Plugin.php
+++ b/tests/_support/Helper/Acceptance/Plugin.php
@@ -421,6 +421,7 @@ public function setupConvertKitPluginBroadcasts($I, $settings = false)
case 'post_status':
case 'category_id':
+ case 'author_id':
$I->fillSelect2Field($I, '#select2-_wp_convertkit_settings_broadcasts_' . $key . '-container', $value);
break;
diff --git a/tests/acceptance/broadcasts/import/BroadcastsToPostsCest.php b/tests/acceptance/broadcasts/import/BroadcastsToPostsCest.php
index c13dac129..f647f77e6 100644
--- a/tests/acceptance/broadcasts/import/BroadcastsToPostsCest.php
+++ b/tests/acceptance/broadcasts/import/BroadcastsToPostsCest.php
@@ -284,6 +284,66 @@ public function testBroadcastsImportWithPostStatusEnabled(AcceptanceTester $I)
}
}
+ /**
+ * Tests that Broadcasts import when enabled in the Plugin's settings,
+ * an Author is defined and the Author is assigned to the created
+ * WordPress Posts.
+ *
+ * @since 2.3.8
+ *
+ * @param AcceptanceTester $I Tester.
+ */
+ public function testBroadcastsImportWithAuthorIDEnabled(AcceptanceTester $I)
+ {
+ // Add a WordPress User with an Editor role.
+ $I->haveUserInDatabase( 'editor', 'editor' );
+
+ // Enable Broadcasts to Posts.
+ $I->setupConvertKitPluginBroadcasts(
+ $I,
+ [
+ 'enabled' => true,
+ 'author_id' => 'editor',
+ 'category_id' => $this->categoryName,
+ 'published_at_min_date' => '01/01/2020',
+ ]
+ );
+
+ // Run the WordPress Cron event to import Broadcasts to WordPress Posts.
+ $I->runCronEvent($I, $this->cronEventName);
+
+ // Wait a few seconds for the Cron event to complete importing Broadcasts.
+ $I->wait(7);
+
+ // Load the Posts screen.
+ $I->amOnAdminPage('edit.php');
+
+ // Check that no PHP warnings or notices were output.
+ $I->checkNoWarningsAndNoticesOnScreen($I);
+
+ // Confirm expected Broadcasts exist as Posts.
+ $I->see($_ENV['CONVERTKIT_API_BROADCAST_FIRST_TITLE']);
+ $I->see($_ENV['CONVERTKIT_API_BROADCAST_SECOND_TITLE']);
+ $I->see($_ENV['CONVERTKIT_API_BROADCAST_THIRD_TITLE']);
+
+ // Get created Post IDs.
+ $postIDs = [
+ (int) str_replace('post-', '', $I->grabAttributeFrom('tbody#the-list > tr:nth-child(1)', 'id')),
+ (int) str_replace('post-', '', $I->grabAttributeFrom('tbody#the-list > tr:nth-child(2)', 'id')),
+ (int) str_replace('post-', '', $I->grabAttributeFrom('tbody#the-list > tr:nth-child(3)', 'id')),
+ ];
+
+ // Confirm each Post's status is private.
+ foreach ($postIDs as $postID) {
+ $I->seePostInDatabase(
+ [
+ 'ID' => $postID,
+ 'post_author' => '2',
+ ]
+ );
+ }
+ }
+
/**
* Tests that Broadcasts import when enabled in the Plugin's settings
* a Category is defined and the Category is assigned to the created
diff --git a/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php b/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php
index 9db84497f..8a514851f 100644
--- a/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php
+++ b/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php
@@ -38,6 +38,7 @@ public function testAccessibility(AcceptanceTester $I)
// Confirm that settings have label[for] attributes.
$I->seeInSource('