PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.4.7
GiveWP – Donation Plugin and Fundraising Platform v2.4.7
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 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / donors / donor-actions.php
give / includes / admin / donors Last commit date
class-donor-table.php 7 years ago donor-actions.php 7 years ago donor-functions.php 7 years ago donors.php 7 years ago
donor-actions.php
631 lines
1 <?php
2 /**
3 * Donors
4 *
5 * @package Give
6 * @subpackage Admin/Donors
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Processes a donor edit.
19 *
20 * @param array $args The $_POST array being passed.
21 *
22 * @since 1.0
23 *
24 * @return array|bool $output Response messages
25 */
26 function give_edit_donor( $args ) {
27
28 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
29
30 if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31 wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array(
32 'response' => 403,
33 ) );
34 }
35
36 if ( empty( $args ) ) {
37 return false;
38 }
39
40 // Sanitize Data.
41 $args = give_clean( $args );
42
43 $args = wp_parse_args(
44 $args,
45 array(
46 'give_anonymous_donor' => 0
47 )
48 );
49
50 // Verify Nonce.
51 if ( ! wp_verify_nonce( $args['_wpnonce'], 'edit-donor' ) ) {
52 wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array(
53 'response' => 400,
54 ) );
55 }
56
57 $donor_info = $args['donor_info'];
58 $donor_id = intval( $donor_info['id'] );
59
60 $donor = new Give_Donor( $donor_id );
61
62 // Bailout, if donor id doesn't exists.
63 if ( empty( $donor->id ) ) {
64 return false;
65 }
66
67 $defaults = array(
68 'title' => '',
69 'name' => '',
70 'user_id' => 0,
71 'line1' => '',
72 'line2' => '',
73 'city' => '',
74 'zip' => '',
75 'state' => '',
76 'country' => '',
77 );
78
79 $donor_info = wp_parse_args( $donor_info, $defaults );
80
81 if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
82
83 // Make sure we don't already have this user attached to a donor.
84 if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
85 give_set_error(
86 'give-invalid-donor-user_id',
87 sprintf(
88 /* translators: %d User ID */
89 __( 'The User ID #%d is already associated with a different donor.', 'give' ),
90 $donor_info['user_id']
91 )
92 );
93 }
94
95 // Make sure it's actually a user.
96 $user = get_user_by( 'id', $donor_info['user_id'] );
97 if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
98 give_set_error(
99 'give-invalid-user_id',
100 sprintf(
101 /* translators: %d User ID */
102 __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ),
103 $donor_info['user_id']
104 )
105 );
106 }
107 }
108
109 // Bailout, if errors are present.
110 if ( give_get_errors() ) {
111 return false;
112 }
113
114 $donor->update_meta( '_give_anonymous_donor', absint( $args['give_anonymous_donor'] ) );
115
116 // Save company name in when admin update donor company name from dashboard.
117 $donor->update_meta( '_give_donor_company', sanitize_text_field( $args['give_donor_company'] ) );
118
119 // If First name of donor is empty, then fetch the current first name of donor.
120 if ( empty( $donor_info['first_name'] ) ) {
121 $donor_info['first_name'] = $donor->get_first_name();
122 }
123
124 // Sanitize the inputs.
125 $donor_data = array();
126 $donor_data['name'] = trim( "{$donor_info['first_name']} {$donor_info['last_name']}" );
127 $donor_data['first_name'] = $donor_info['first_name'];
128 $donor_data['last_name'] = $donor_info['last_name'];
129 $donor_data['title'] = $donor_info['title'];
130 $donor_data['user_id'] = $donor_info['user_id'];
131
132 $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
133
134 /**
135 * Filter the address
136 *
137 * @todo unnecessary filter because we are not storing donor address to user.
138 *
139 * @since 1.0
140 */
141 $address = apply_filters( 'give_edit_donor_address', array(), $donor_id );
142
143 $donor_data = give_clean( $donor_data );
144 $address = give_clean( $address );
145
146 $output = give_connect_user_donor_profile( $donor, $donor_data, $address );
147
148 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
149 header( 'Content-Type: application/json' );
150 echo wp_json_encode( $output );
151 wp_die();
152 }
153
154 if ( $output['success'] ) {
155 wp_safe_redirect( add_query_arg(
156 array(
157 'post_type' => 'give_forms',
158 'page' => 'give-donors',
159 'view' => 'overview',
160 'id' => $donor_id,
161 'give-messages[]' => 'profile-updated'
162 ),
163 esc_url( admin_url( 'edit.php' ) )
164 ) );
165 }
166
167 exit;
168
169 }
170
171 add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
172
173 /**
174 * Save a donor note.
175 *
176 * @param array $args The $_POST array being passed.
177 *
178 * @since 1.0
179 *
180 * @return int The Note ID that was saved, or 0 if nothing was saved.
181 */
182 function give_donor_save_note( $args ) {
183
184 $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
185
186 if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
187 wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
188 'response' => 403,
189 ) );
190 }
191
192 if ( empty( $args ) ) {
193 return false;
194 }
195
196 $donor_note = trim( give_clean( $args['donor_note'] ) );
197 $donor_id = (int) $args['customer_id'];
198 $nonce = $args['add_donor_note_nonce'];
199
200 if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
201 wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
202 'response' => 400,
203 ) );
204 }
205
206 if ( empty( $donor_note ) ) {
207 give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
208 }
209
210 if ( give_get_errors() ) {
211 return false;
212 }
213
214 $donor = new Give_Donor( $donor_id );
215 $new_note = $donor->add_note( $donor_note );
216
217 /**
218 * Fires before inserting donor note.
219 *
220 * @param int $donor_id The ID of the donor.
221 * @param string $new_note Note content.
222 *
223 * @since 1.0
224 */
225 do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
226
227 if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
228
229 ob_start();
230 ?>
231 <div class="donor-note-wrapper dashboard-comment-wrap comment-item">
232 <span class="note-content-wrap">
233 <?php echo stripslashes( $new_note ); ?>
234 </span>
235 </div>
236 <?php
237 $output = ob_get_contents();
238 ob_end_clean();
239
240 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
241 echo $output;
242 exit;
243 }
244
245 return $new_note;
246
247 }
248
249 return false;
250
251 }
252
253 add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
254
255
256 /**
257 * Disconnect a user ID from a donor
258 *
259 * @param array $args Array of arguments.
260 *
261 * @since 1.0
262 *
263 * @return bool|array If the disconnect was successful.
264 */
265 function give_disconnect_donor_user_id( $args ) {
266
267 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
268
269 if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
270 wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
271 'response' => 403,
272 ) );
273 }
274
275 if ( empty( $args ) ) {
276 return false;
277 }
278
279 $donor_id = (int) $args['customer_id'];
280
281 $nonce = $args['_wpnonce'];
282
283 if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
284 wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
285 'response' => 400,
286 ) );
287 }
288
289 $donor = new Give_Donor( $donor_id );
290 if ( empty( $donor->id ) ) {
291 return false;
292 }
293
294 $user_id = $donor->user_id;
295
296 /**
297 * Fires before disconnecting user ID from a donor.
298 *
299 * @param int $donor_id The ID of the donor.
300 * @param int $user_id The ID of the user.
301 *
302 * @since 1.0
303 */
304 do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
305
306 $output = array();
307 $donor_args = array(
308 'user_id' => 0,
309 );
310
311
312 $output['success'] = true;
313 if ( ! $donor->update( $donor_args ) ) {
314 update_user_meta( $user_id, '_give_is_donor_disconnected', true );
315 update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
316 $donor->update_meta( '_give_disconnected_user_id', $user_id );
317
318 $output['success'] = true;
319
320 } else {
321 $output['success'] = false;
322 give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
323 }
324
325 $output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
326
327 /**
328 * Fires after disconnecting user ID from a donor.
329 *
330 * @param int $donor_id The ID of the donor.
331 *
332 * @since 1.0
333 */
334 do_action( 'give_post_donor_disconnect_user_id', $donor_id );
335
336 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
337 header( 'Content-Type: application/json' );
338 echo json_encode( $output );
339 wp_die();
340 }
341
342 return $output;
343
344 }
345
346 add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
347
348 /**
349 * Add an email address to the donor from within the admin and log a donor note.
350 *
351 * @param array $args Array of arguments: nonce, donor id, and email address.
352 *
353 * @since 1.7
354 *
355 * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
356 */
357 function give_add_donor_email( $args ) {
358
359 $donor_id = '';
360 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
361
362 if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
363 wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
364 'response' => 403,
365 ) );
366 }
367
368 $output = array();
369 if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
370 $output['success'] = false;
371 if ( empty( $args['email'] ) ) {
372 $output['message'] = __( 'Email address is required.', 'give' );
373 } elseif ( empty( $args['customer_id'] ) ) {
374 $output['message'] = __( 'Donor ID is required.', 'give' );
375 } else {
376 $output['message'] = __( 'An error has occurred. Please try again.', 'give' );
377 }
378 } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
379 $output = array(
380 'success' => false,
381 'message' => __( 'Nonce verification failed.', 'give' ),
382 );
383 } elseif ( ! is_email( $args['email'] ) ) {
384 $output = array(
385 'success' => false,
386 'message' => __( 'Invalid email.', 'give' ),
387 );
388 } else {
389 $email = sanitize_email( $args['email'] );
390 $donor_id = (int) $args['customer_id'];
391 $primary = 'true' === $args['primary'] ? true : false;
392 $donor = new Give_Donor( $donor_id );
393 if ( false === $donor->add_email( $email, $primary ) ) {
394 if ( in_array( $email, $donor->emails ) ) {
395 $output = array(
396 'success' => false,
397 'message' => __( 'Email already associated with this donor.', 'give' ),
398 );
399 } else {
400 $output = array(
401 'success' => false,
402 'message' => __( 'Email address is already associated with another donor.', 'give' ),
403 );
404 }
405 } else {
406 $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-messages[]=email-added' );
407 $output = array(
408 'success' => true,
409 'message' => __( 'Email successfully added to donor.', 'give' ),
410 'redirect' => $redirect,
411 );
412
413 $user = wp_get_current_user();
414 $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
415 $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
416 $donor->add_note( $donor_note );
417
418 if ( $primary ) {
419 $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
420 $donor->add_note( $donor_note );
421 }
422 }
423 } // End if().
424
425 do_action( 'give_post_add_donor_email', $donor_id, $args );
426
427 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
428 header( 'Content-Type: application/json' );
429 echo json_encode( $output );
430 wp_die();
431 }
432
433 return $output;
434 }
435
436 add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
437
438
439 /**
440 * Remove an email address to the donor from within the admin and log a donor note and redirect back to the donor interface for feedback.
441 *
442 * @since 1.7
443 *
444 * @return bool|null
445 */
446 function give_remove_donor_email() {
447 if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
448 return false;
449 }
450 if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
451 return false;
452 }
453 if ( empty( $_GET['_wpnonce'] ) ) {
454 return false;
455 }
456
457 $nonce = $_GET['_wpnonce'];
458 if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
459 wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
460 'response' => 403,
461 ) );
462 }
463
464 $donor = new Give_Donor( $_GET['id'] );
465 if ( $donor->remove_email( $_GET['email'] ) ) {
466 $url = add_query_arg( 'give-messages[]', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
467 $user = wp_get_current_user();
468 $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
469 $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
470 $donor->add_note( $donor_note );
471 } else {
472 $url = add_query_arg( 'give-messages[]', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
473 }
474
475 wp_safe_redirect( $url );
476 exit;
477 }
478
479 add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
480
481
482 /**
483 * Set an email address as the primary for a donor from within the admin and log a donor note
484 * and redirect back to the donor interface for feedback
485 *
486 * @since 1.7
487 *
488 * @return bool|null
489 */
490 function give_set_donor_primary_email() {
491 if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
492 return false;
493 }
494
495 if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
496 return false;
497 }
498
499 if ( empty( $_GET['_wpnonce'] ) ) {
500 return false;
501 }
502
503 $nonce = $_GET['_wpnonce'];
504
505 if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
506 wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
507 'response' => 403,
508 ) );
509 }
510
511 $donor = new Give_Donor( $_GET['id'] );
512
513 if ( $donor->set_primary_email( $_GET['email'] ) ) {
514 $url = add_query_arg( 'give-messages[]', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
515 $user = wp_get_current_user();
516 $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
517 $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
518
519 $donor->add_note( $donor_note );
520 } else {
521 $url = add_query_arg( 'give-messages[]', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
522 }
523
524 wp_safe_redirect( $url );
525 exit;
526 }
527
528 add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
529
530
531 /**
532 * This function will process the donor deletion.
533 *
534 * @param array $args Donor Deletion Arguments.
535 *
536 * @since 2.2
537 */
538 function give_process_donor_deletion( $args ) {
539 // Bailout.
540 if ( ! isset( $args['give-donor-delete-confirm'] ) ) {
541 return;
542 }
543
544 $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
545
546 // Verify user capabilities to proceed for deleting donor.
547 if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
548 wp_die(
549 esc_html__( 'You do not have permission to delete donors.', 'give' ),
550 esc_html__( 'Error', 'give' ),
551 array(
552 'response' => 403,
553 )
554 );
555 }
556
557 $nonce_action = '';
558 if ( 'delete_bulk_donor' === $args['give_action'] ) {
559 $nonce_action = 'bulk-donors';
560 } elseif ( 'delete_donor' === $args['give_action'] ) {
561 $nonce_action = 'give-delete-donor';
562 }
563
564 // Verify Nonce for deleting bulk donors.
565 give_validate_nonce( $args['_wpnonce'], $nonce_action );
566
567 $redirect_args = array();
568 $donor_ids = ( isset( $args['donor'] ) && is_array( $args['donor'] ) ) ? $args['donor'] : array( $args['donor_id'] );
569 $redirect_args['order'] = ! empty( $args['order'] ) ? $args['order'] : 'DESC';
570 $redirect_args['orderby'] = ! empty( $args['orderby'] ) ? strtolower( $args['orderby'] ) : 'id';
571 $redirect_args['s'] = ! empty( $args['s'] ) ? $args['s'] : '';
572 $delete_donor = ! empty( $args['give-donor-delete-confirm'] ) ? give_is_setting_enabled( $args['give-donor-delete-confirm'] ) : false;
573 $delete_donation = ! empty( $args['give-donor-delete-records'] ) ? give_is_setting_enabled( $args['give-donor-delete-records'] ) : false;
574
575 if ( count( $donor_ids ) > 0 ) {
576
577 // Loop through the selected donors to delete.
578 foreach ( $donor_ids as $donor_id ) {
579
580 $donor = new Give_Donor( $donor_id );
581
582 // Proceed only if valid donor id is provided.
583 if ( $donor->id > 0 ) {
584
585 /**
586 * Fires before deleting donor.
587 *
588 * @param int $donor_id The ID of the donor.
589 * @param bool $delete_donor Confirm Donor Deletion.
590 * @param bool $delete_donation Confirm Donor related donations deletion.
591 *
592 * @since 1.0
593 */
594 do_action( 'give_pre_delete_donor', $donor->id, $delete_donor, $delete_donation );
595
596 // Proceed only, if user confirmed whether they need to delete the donor.
597 if ( $delete_donor ) {
598
599 // Delete donor and linked donations.
600 $donor_delete_status = give_delete_donor_and_related_donation( $donor, array(
601 'delete_donation' => $delete_donation,
602 ) );
603
604 if ( 1 === $donor_delete_status ) {
605 $redirect_args['give-messages[]'] = 'donor-deleted';
606 } elseif ( 2 === $donor_delete_status ) {
607 $redirect_args['give-messages[]'] = 'donor-donations-deleted';
608 }
609 } else {
610 $redirect_args['give-messages[]'] = 'confirm-delete-donor';
611 }
612 } else {
613 $redirect_args['give-messages[]'] = 'invalid-donor-id';
614 } // End if().
615 } // End foreach().
616 } else {
617 $redirect_args['give-messages[]'] = 'no-donor-found';
618 } // End if().
619
620 $redirect_url = add_query_arg(
621 $redirect_args,
622 admin_url( 'edit.php?post_type=give_forms&page=give-donors' )
623 );
624
625 wp_safe_redirect( $redirect_url );
626 give_die();
627
628 }
629 add_action( 'give_delete_donor', 'give_process_donor_deletion' );
630 add_action( 'give_delete_bulk_donor', 'give_process_donor_deletion' );
631