From b4a221837e08a184d916af012af15eca4804319c Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Thu, 3 Oct 2024 13:04:20 +0300 Subject: [PATCH] * fixed first install scripts; --- includes/common/class-cpt.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/common/class-cpt.php b/includes/common/class-cpt.php index f5751226..022fee00 100644 --- a/includes/common/class-cpt.php +++ b/includes/common/class-cpt.php @@ -159,7 +159,16 @@ if ( ! class_exists( 'um\common\CPT' ) ) { $mode = 'members'; if ( 'um_form' === $post->post_type ) { $meta_value_mode = get_post_meta( $post_id, '_um_mode', true ); - $mode = ! empty( $meta_value_mode ) ? $meta_value_mode : sanitize_key( $_POST['form']['_um_mode'] ); // phpcs:ignore WordPress.Security.NonceVerification -- already verified here + if ( ! empty( $meta_value_mode ) ) { + $mode = $meta_value_mode; + } elseif ( ! empty( $_POST['form']['_um_mode'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification -- already verified here + $mode = sanitize_key( $_POST['form']['_um_mode'] ); // phpcs:ignore WordPress.Security.NonceVerification -- already verified here + } + } + + // $mode can be empty on the first installation + if ( empty( $mode ) ) { + return; } // Set current published form or member directory as predefined in the case when old default doesn't exist or hasn't a `publish` status.