| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @version 1.0 |
| 4 | 4 | * @package Booking Calendar |
| @@ -116,11 +116,26 @@ | ||
| 116 | 116 | $sanitized_data[ $key ] = is_array( $val ) ? array_map( 'sanitize_text_field', $val ) |
| 117 | 117 | : sanitize_text_field( $val ); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - update_user_option( $user_id, self::$user_option_prefix . $data_name, $sanitized_data ); | |
| 121 | - | |
| 122 | - wp_send_json_success( array( 'message' => 'Settings saved successfully.' ) ); | |
| 120 | + $option_name = self::$user_option_prefix . $data_name; | |
| 121 | + update_user_option( $user_id, $option_name, $sanitized_data ); | |
| 122 | + | |
| 123 | + $stored_data = get_user_option( $option_name, $user_id ); | |
| 124 | + if ( ! is_array( $stored_data ) || $sanitized_data !== $stored_data ) { | |
| 125 | + wp_send_json_error( array( 'message' => 'The setting could not be saved. Please reload the page and try again.' ) ); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Fires after Booking Calendar user data has been stored and verified. | |
| 130 | + * | |
| 131 | + * @param int $user_id Current WordPress user ID. | |
| 132 | + * @param string $data_name Sanitized Booking Calendar preference name. | |
| 133 | + * @param array $sanitized_data Sanitized value confirmed in user metadata. | |
| 134 | + */ | |
| 135 | + do_action( 'wpbc_user_custom_data_saved', $user_id, $data_name, $sanitized_data ); | |
| 136 | + | |
| 137 | + wp_send_json_success( array( 'message' => 'Settings saved successfully.' ) ); | |
| 123 | 138 | } |
| 124 | 139 | |
| 125 | 140 | /** |
| 126 | 141 | * Get saved data |
| @@ -249,5 +264,5 @@ | ||
| 249 | 264 | Save Simple Note |
| 250 | 265 | </a> |
| 251 | 266 | <?php |
| 252 | 267 | } |
| 253 | -*/ | |
| 268 | +*/ | |