+} elseif (isFormSent('change')) {
+ // Change receive status, depending on its current state
+ if (isUserDataEnabled('receiving_coupons')) {
+ // Unsubscribe from coupons
+ $message = '{--MEMBER_COUPON_RECEIVE_STATUS_UNSUBSCRIBED--}';
+ $newStatus = 'N';
+ } else {
+ // Subscribe to coupons
+ $message = '{--MEMBER_COUPON_RECEIVE_STATUS_SUBSCRIBED--}';
+ $newStatus = 'Y';
+ }
+
+ // And change it in the database
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receiving_coupons`='%s' WHERE `userid`=%s LIMIT 1",
+ array($newStatus, getMemberId()), __FILE__, __LINE__);
+
+ // Did something change?
+ if (!SQL_HASZEROAFFECTED()) {
+ // Records have been updated
+ displayMessage($message);
+ } else {
+ // Nothing changed!
+ displayMessage('{--MEMBER_COUPON_RECEIVE_STATUS_UNCHANGED--}');
+ }