PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | src/API/REST/V3/Routes/Donors/DonorController.php +26 -6 4.16.1 → 4.17.0 View file →
@@ -188,8 +188,10 @@
188 188
189 189 /**
190 190 * Update a single donor.
191 191 *
192 + * @since 4.17.0 Non-admin callers may no longer add unverified email addresses.
193 + * @since 4.16.6 Skip readonly schema properties when applying PATCH updates.
192 194 * @since 4.8.0 Update donor name when firstName or lastName is updated
193 195 * @since 4.7.0 Add support for updating custom fields
194 196 * @since 4.4.0
195 197 *
@@ -202,16 +204,34 @@
202 204 if (!$donor) {
203 205 return new WP_REST_Response(__('Donor not found', 'give'), 404);
204 206 }
205 207
206 - $nonEditableFields = [
207 - 'id',
208 - 'userId',
209 - 'createdAt',
210 - ];
208 + $nonEditableFields = array_merge(
209 + [
210 + 'id',
211 + 'userId',
212 + 'createdAt',
213 + ],
214 + array_keys(
215 + array_filter(
216 + $this->get_item_schema()['properties'] ?? [],
217 + static function (array $property): bool {
218 + return ! empty($property['readonly']);
219 + }
220 + )
221 + )
222 + );
211 223
224 + if (!DonorPermissions::canEdit() && $request->has_param('additionalEmails')) {
225 + $allowed = array_merge($donor->additionalEmails ?? [], [$donor->email]);
226 + $request->set_param(
227 + 'additionalEmails',
228 + array_values(array_intersect((array)$request->get_param('additionalEmails'), $allowed))
229 + );
230 + }
231 +
212 232 foreach ($request->get_params() as $key => $value) {
213 - if (!in_array($key, $nonEditableFields)) {
233 + if (! in_array($key, $nonEditableFields, true)) {
214 234 if ($donor->hasProperty($key)) {
215 235 if ($key === 'addresses') {
216 236 $donor->addresses = array_map(function ($address) {
217 237 return DonorAddress::fromArray($address);