Skip to content

Commit 42993ab

Browse files
committed
Fix is creating.
1 parent f533972 commit 42993ab

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

app/Hooks/Queue/Post.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,23 @@ public static function save_post_queue(int $queue_id, \WP_Post $post, bool $upda
119119
)
120120
);
121121

122-
$site_id = wp_insert_post(array(
123-
'post_type' => 'site',
124-
'post_title' => esc_html($company_name),
125-
'post_name' => $space_name,
126-
'post_status' => 'publish',
127-
'post_author' => $site_owner->ID,
128-
));
129-
130-
app_log("Site entry for {$company_name} created with ID {$site_id}");
122+
$site_exists = get_page_by_path($space_name, OBJECT, 'site');
123+
if(!$site_exists) {
124+
$site_id = wp_insert_post(array(
125+
'post_type' => 'site',
126+
'post_title' => esc_html($company_name),
127+
'post_name' => $space_name,
128+
'post_status' => 'publish',
129+
'post_author' => $site_owner->ID,
130+
));
131+
132+
app_log("Site entry for {$company_name} created with ID {$site_id}");
133+
} else {
134+
$site_id = $site_exists->ID;
135+
}
136+
131137
update_field('site_uri', $wp_home, $site_id);
138+
132139
foreach ($variables as $key => $variable) {
133140
app_log("Updating {$key} for site {$company_name}");
134141
update_field($key, $variable, $site_id);

resources/scripts/site/components/CreateSiteForm.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const CreateSiteForm = () => {
5858

5959
const handleSubmit = async (e) => {
6060
e.preventDefault();
61+
if(isCreating) return;
6162
setIsCreating(true);
6263

6364
const siteData = {

0 commit comments

Comments
 (0)