/** * Newsletter Unsub Sync — RGPD cross-system compliance * * When someone unsubscribes via the Newsletter plugin (Stefano Lissa), * this syncs the unsub to wp_newsletter_unsubs (Claude Code publipostage table). * Ensures both mailing systems respect the same unsubscribe list. * * @since YIO 1.38.0 * @package YIO */if (!defined('ABSPATH')) { exit; }add_action('newsletter_user_unsubscribed', function ($user) { global $wpdb;if (empty($user->email)) { return; }$email = strtolower(trim($user->email)); $table = 'wp_newsletter_unsubs';// Check if already in Claude Code unsub table $exists = $wpdb->get_var($wpdb->prepare( "SELECT id FROM {$table} WHERE email = %s", $email ));if ($exists) { return; }// Insert into Claude Code unsub table $wpdb->insert($table, [ 'email' => $email, 'campaign_id' => 'newsletter_plugin_sync', 'unsub_date' => current_time('mysql'), 'ip_address' => '', 'method' => 'newsletter_plugin', ]);if (function_exists('yoyaku_log')) { yoyaku_log("Newsletter unsub synced to publipostage: {$email}", 'info', ['source' => 'yio']); } }); /** * Newsletter Unsubscribe Handler * Shortcode [ysc_newsletter_unsub] — processes unsub requests from email links */ add_shortcode("ysc_newsletter_unsub", function () { global $wpdb;$email_b64 = isset($_GET["email"]) ? $_GET["email"] : ""; $token = isset($_GET["token"]) ? $_GET["token"] : ""; $campaign = isset($_GET["c"]) ? sanitize_text_field($_GET["c"]) : "";if (empty($email_b64)) { return "

Unsubscribe

Missing email parameter.

"; }$email = strtolower(trim(base64_decode($email_b64))); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return "

Unsubscribe

Invalid email address.

"; }// Verify token $expected = substr(md5($email . "yoyaku_newsletter_" . $campaign), 0, 12); if ($token !== $expected) { return "

Unsubscribe

Invalid token. Please use the link from your email.

"; }// Add to unsub table $exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM wp_newsletter_unsubs WHERE email=%s", $email)); if (!$exists) { $wpdb->insert("wp_newsletter_unsubs", [ "email" => $email, "campaign_id" => $campaign ?: "direct_unsub", "unsub_date" => current_time("mysql"), "ip_address" => $_SERVER["REMOTE_ADDR"] ?? "", "method" => "unsub_page" ]); }// Also update Newsletter plugin if user exists there $nl_user = $wpdb->get_row($wpdb->prepare("SELECT id FROM {$wpdb->prefix}newsletter WHERE email=%s", $email)); if ($nl_user) { $wpdb->update($wpdb->prefix . "newsletter", ["status" => "U"], ["id" => $nl_user->id]); }return "

Unsubscribed

You have been unsubscribed from our mailing list.

You will no longer receive promotional emails from Yoyaku Record Store.

Back to Yoyaku

"; }); Enrica Falqui – Yoyaku Record Store

Enrica Falqui

Enrica Falqui

Born in Sardinia, now based in Berlin. Half of techno project Eris, half of ambient/experimental project Yhdessa.

aka Enrica
No products were found matching your selection.
80%
0