← All changes
|
includes/admin/onboarding/class-charitable-setup.php
+18
-9
1.8.13
→
1.8.13.1
View file →
| @@ -1109,20 +1109,29 @@ | ||
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | // setup variables. |
| 1112 | 1112 | $opt_in_tracking = empty( $_POST['tracking_action'] ) || $_POST['tracking_action'] === 'opt-out' ? '0' : '1'; |
| 1113 | - $email = update_option( 'charitable_email_signup', false ) ? get_option( 'charitable_email_signup' ) : get_option( 'admin_email' ); | |
| 1114 | 1113 | |
| 1114 | + // Was update_option() where get_option() was meant, which wiped the stored address. | |
| 1115 | + $email = get_option( 'charitable_email_signup' ) ? get_option( 'charitable_email_signup' ) : get_option( 'admin_email' ); | |
| 1116 | + | |
| 1117 | + $tracking_args = array( | |
| 1118 | + 'opt_in_track' => $opt_in_tracking, | |
| 1119 | + 'site_token' => charitable_get_site_token(), | |
| 1120 | + 'return' => rawurlencode( | |
| 1121 | + base64_encode( get_admin_url( null, 'admin.php') ) // phpcs:ignore | |
| 1122 | + ), | |
| 1123 | + ); | |
| 1124 | + | |
| 1125 | + // Never send the address on a decline. The app resolves the record by site_token and only | |
| 1126 | + // falls back to `email` when that misses, so omitting it still records the opt-out. | |
| 1127 | + if ( '1' === $opt_in_tracking && is_email( $email ) ) { | |
| 1128 | + $tracking_args['email'] = $email; | |
| 1129 | + } | |
| 1130 | + | |
| 1115 | 1131 | // assemble a url to the setup wizard using WordPress function. |
| 1116 | 1132 | $tracking_update_url = add_query_arg( |
| 1117 | - array( | |
| 1118 | - 'email' => is_email( $email ) ? $email : false, | |
| 1119 | - 'opt_in_track' => $opt_in_tracking, | |
| 1120 | - 'site_token' => charitable_get_site_token(), | |
| 1121 | - 'return' => rawurlencode( | |
| 1122 | - base64_encode( get_admin_url( null, 'admin.php') ) // phpcs:ignore | |
| 1123 | - ), | |
| 1124 | - ), | |
| 1133 | + $tracking_args, | |
| 1125 | 1134 | charitable_onboarding_app_url() . '/optin-charitable_tracking' |
| 1126 | 1135 | ); |
| 1127 | 1136 | |
| 1128 | 1137 | // Send the POST request. |