diff --git a/admin/form-builder/views/post-form-settings.php b/admin/form-builder/views/post-form-settings.php
index 5f6f48a2c..515e391ee 100644
--- a/admin/form-builder/views/post-form-settings.php
+++ b/admin/form-builder/views/post-form-settings.php
@@ -313,6 +313,8 @@ function wpuf_render_settings_field( $field_key, $field, $form_settings, $post_t
$value = ! empty( $field['default'] ) ? $field['default'] : '';
$value = ! empty( $field['value'] ) ? $field['value'] : $value; // default value
+ $is_pro_preview = ! empty( $field['pro_preview'] ) || ( ! wpuf_is_pro_active() && in_array( $field_key, [ 'notification_edit', 'notification_edit_to', 'notification_edit_subject', 'notification_edit_body' ] ) );
+
// replace default value if already saved in DB
if ( ! empty( $field['name'] ) ) {
preg_match('/wpuf_settings\[(.*?)\]\[(.*?)\]/', $field['name'], $matches);
@@ -327,7 +329,9 @@ function wpuf_render_settings_field( $field_key, $field, $form_settings, $post_t
}
// if the field is a pro fields preview, no need to load fields from db
- if ( empty( $field['pro_preview'] ) ) {
+ if ( $is_pro_preview ) {
+ $value = ! empty( $field['value'] ) ? $field['value'] : $value;
+ } else {
$value = isset( $form_settings[ $field_key ] ) ? $form_settings[ $field_key ] : $value; // checking with isset because saved value can be empty string
}
@@ -342,8 +346,9 @@ function wpuf_render_settings_field( $field_key, $field, $form_settings, $post_t
+
id=""/>
';
}
?>
-
+
@@ -458,8 +470,9 @@ class="fa fa-angle-down !wpuf-font-bold !wpuf-text-xl !wpuf-leading-none wpuf-te
+
id=""
value=""/>
@@ -470,7 +483,8 @@ class="fa fa-angle-down !wpuf-font-bold !wpuf-text-xl !wpuf-leading-none wpuf-te
diff --git a/includes/Admin/Forms/Admin_Form_Builder.php b/includes/Admin/Forms/Admin_Form_Builder.php
index 60d4d0681..957152055 100644
--- a/includes/Admin/Forms/Admin_Form_Builder.php
+++ b/includes/Admin/Forms/Admin_Form_Builder.php
@@ -337,7 +337,7 @@ private function i18n() {
*
* @param array $data Contains form_fields, form_settings, form_settings_key data
*
- * @return bool
+ * @return array
*/
public static function save_form( $data ) {
$saved_wpuf_inputs = [];
@@ -373,6 +373,29 @@ public static function save_form( $data ) {
wp_delete_post( $delete_id, true );
}
}
+
+ // Filter out pro notification settings if pro version is not active
+ if ( ! wpuf_is_pro_active() && isset( $data['form_settings']['notification'] ) ) {
+ // Remove update post notification settings for free version
+ if ( isset( $data['form_settings']['notification']['edit'] ) ) {
+ unset( $data['form_settings']['notification']['edit'] );
+ }
+ if ( isset( $data['form_settings']['notification']['edit_to'] ) ) {
+ unset( $data['form_settings']['notification']['edit_to'] );
+ }
+ if ( isset( $data['form_settings']['notification']['edit_subject'] ) ) {
+ unset( $data['form_settings']['notification']['edit_subject'] );
+ }
+ if ( isset( $data['form_settings']['notification']['edit_body'] ) ) {
+ unset( $data['form_settings']['notification']['edit_body'] );
+ }
+ }
+
+ // Also filter out standalone notification_edit field if it exists
+ if ( ! wpuf_is_pro_active() && isset( $data['form_settings']['notification_edit'] ) ) {
+ unset( $data['form_settings']['notification_edit'] );
+ }
+
update_post_meta( $data['form_id'], $data['form_settings_key'], $data['form_settings'] );
update_post_meta( $data['form_id'], 'notifications', $data['notifications'] );
update_post_meta( $data['form_id'], 'integrations', $data['integrations'] );
diff --git a/includes/Free/Free_Loader.php b/includes/Free/Free_Loader.php
index fc845faab..c26f3e3d2 100644
--- a/includes/Free/Free_Loader.php
+++ b/includes/Free/Free_Loader.php
@@ -6,6 +6,7 @@
use WeDevs\Wpuf\Admin\Forms\Post\Templates\Post_Form_Template_WooCommerce;
use WeDevs\Wpuf\Admin\Forms\Post\Templates\Pro_Form_Preview_EDD;
use WeDevs\Wpuf\Pro\Admin\Coupon_Elements;
+use WeDevs\Wpuf\Hooks\Form_Settings_Cleanup;
class Free_Loader extends Pro_Prompt {
@@ -72,6 +73,7 @@ public function run_hooks() {
public function includes() {
// class files to include pro elements
require_once WPUF_INCLUDES . '/functions/user/edit-user.php';
+ require_once WPUF_INCLUDES . '/Hooks/Form_Settings_Cleanup.php';
}
public function instantiate() {
@@ -90,6 +92,7 @@ public function instantiate() {
if ( $load_free ) {
new WPUF_Admin_Form_Free();
+ new Form_Settings_Cleanup();
}
}
}
diff --git a/includes/Hooks/Form_Settings_Cleanup.php b/includes/Hooks/Form_Settings_Cleanup.php
new file mode 100644
index 000000000..dc6dd2f42
--- /dev/null
+++ b/includes/Hooks/Form_Settings_Cleanup.php
@@ -0,0 +1,107 @@
+remove_pro_notification_settings( $form_settings );
+
+ // Update if settings were modified
+ if ( $cleaned_settings !== $form_settings ) {
+ update_post_meta( $form_id, 'wpuf_form_settings', $cleaned_settings );
+ }
+ }
+
+ /**
+ * Clean up pro settings from post meta
+ *
+ * @param int $post_id Post ID
+ * @param \WP_Post $post Post object
+ */
+ public function cleanup_form_meta_pro_settings( $post_id, $post ) {
+ if ( wpuf_is_pro_active() || $post->post_type !== 'wpuf_forms' ) {
+ return;
+ }
+
+ $form_settings = get_post_meta( $post_id, 'wpuf_form_settings', true );
+
+ if ( empty( $form_settings ) ) {
+ return;
+ }
+
+ $cleaned_settings = $this->remove_pro_notification_settings( $form_settings );
+
+ // Update if settings were modified
+ if ( $cleaned_settings !== $form_settings ) {
+ update_post_meta( $post_id, 'wpuf_form_settings', $cleaned_settings );
+ }
+ }
+
+ /**
+ * Remove pro notification settings from form settings
+ *
+ * @param array $form_settings Form settings array
+ * @return array Cleaned form settings
+ */
+ private function remove_pro_notification_settings( $form_settings ) {
+ if ( ! is_array( $form_settings ) ) {
+ return $form_settings;
+ }
+
+ // List of pro-only notification settings to remove
+ $pro_notification_keys = [
+ 'notification_edit',
+ 'notification_edit_to',
+ 'notification_edit_subject',
+ 'notification_edit_body'
+ ];
+
+ foreach ( $pro_notification_keys as $key ) {
+ if ( isset( $form_settings[ $key ] ) ) {
+ unset( $form_settings[ $key ] );
+ }
+ }
+
+ if ( isset( $form_settings['notification'] ) && is_array( $form_settings['notification'] ) ) {
+ $notification_pro_keys = [ 'edit', 'edit_to', 'edit_subject', 'edit_body' ];
+
+ foreach ( $notification_pro_keys as $key ) {
+ if ( isset( $form_settings['notification'][ $key ] ) ) {
+ unset( $form_settings['notification'][ $key ] );
+ }
+ }
+ }
+
+ return $form_settings;
+ }
+}