@@ -1140,28 +1140,37 @@ public function loadCustomFields(string $area = 'summary'): void
11401140 }
11411141
11421142 /**
1143- * Loads the theme options for the member.
1143+ * Populates Utils::$context['member']['options'] with this member's theme
1144+ * options.
11441145 *
1145- * @param bool $defaultSettings If true, we are loading default options.
1146+ * @param ?bool $default_only If true, only load options for the default
1147+ * theme, where "default theme" means whichever theme is used for guests.
1148+ * Default: false.
11461149 */
1147- public function loadThemeOptions (bool $ defaultSettings = false )
1150+ public function loadThemeOptions (bool $ default_only = false )
11481151 {
1149- if (isset ($ _POST ['default_options ' ])) {
1150- $ _POST ['options ' ] = isset ($ _POST ['options ' ]) ? $ _POST ['options ' ] + $ _POST ['default_options ' ] : $ _POST ['default_options ' ];
1152+ // Get this member's current theme options.
1153+ if ($ default_only && $ this ->theme != (Config::$ modSettings ['theme_guests ' ] ?? 1 )) {
1154+ $ temp = $ this ->data ['options ' ] ?? [];
1155+ parent ::loadOptions ($ this ->id , $ default_only );
1156+ Utils::$ context ['member ' ]['options ' ] = $ this ->data ['options ' ];
1157+ $ this ->data ['options ' ] = $ temp ;
1158+ } else {
1159+ Utils::$ context ['member ' ]['options ' ] = $ this ->data ['options ' ] ?? [];
11511160 }
11521161
1153- Utils::$ context ['member ' ]['options ' ] = $ this ->data ['options ' ] ?? [];
1162+ // Overwrite their current options with anything that is being set to a
1163+ // new value.
1164+ $ _POST ['options ' ] = ($ _POST ['options ' ] ?? []) + ($ _POST ['default_options ' ] ?? []);
11541165
1155- if (isset ($ _POST ['options ' ]) && \is_array ($ _POST ['options ' ])) {
1156- foreach ($ _POST ['options ' ] as $ k => $ v ) {
1157- Utils::$ context ['member ' ]['options ' ][$ k ] = $ v ;
1158- }
1166+ foreach ($ _POST ['options ' ] as $ k => $ v ) {
1167+ Utils::$ context ['member ' ]['options ' ][$ k ] = $ v ;
11591168 }
11601169
1161- // Load up the default theme options for any missing.
1162- parent ::loadOptions (-1 );
1170+ // If any theme options are still missing, set them to default values .
1171+ parent ::loadOptions (-1 , $ default_only );
11631172
1164- foreach (parent ::$ profiles [-1 ]['options ' ] as $ k => $ v ) {
1173+ foreach (parent ::$ profiles [-1 ]['options ' ] ?? [] as $ k => $ v ) {
11651174 if (!isset (Utils::$ context ['member ' ]['options ' ][$ k ])) {
11661175 Utils::$ context ['member ' ]['options ' ][$ k ] = $ v ;
11671176 }
0 commit comments