Jake Vanderwerf
2025-11-10 3241a281b1f854dd848156cd9ca54de0e607f08c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<?php
 
$jvbEmail = add_filter('jvb_email', 'altr_email');
 
function altr_email(array $defaults):array
{
    return [
        'colours'       => [
            'action-0'      => '#ff0080',
            'action-50'     => '#ff2492',
            'action-100'    => '#ff47a4',
            'action-200'    => '#ff6bb5',
            'secondary-0'   => '#D69121',
            'secondary-50'  => '#ffc421',
            'secondary-100' => '#ffcd44',
            'secondary-200' => '#ffd768',
            'light'         => '#efefef',
            'light-50'      => '#e2e2e2',
            'light-100'     => '#d5d5d5',
            'light-200'     => '#c9c9c9',
            'dark'          => '#151515',
            'dark-50'       => '#222222',
            'dark-100'      => '#2e2e2e',
            'dark-200'      => '#3b3b3b',
            'action-contrast'=> '',
            'secondary-contrast'=> '',
        ],
        'content'       => [
            'title'             => get_bloginfo('name'),
            'subjectPrefix'     => '['.get_bloginfo('name').']',
            'signature'         => '<p>&emsp; —  ♡ the edmonton.ink crew</p>',
            'footer'    => [
                '<p>&copy; ' . date('Y') . ' edmonton.ink — Your tattoo scene on your screen.</p>',
                '<p><a href="' . get_home_url() . '" class="text-link">edmonton.ink</a></p>'
            ]
        ],
        'types' => [
            'newUser' => [
                'subject'       => 'Welcome to Legacy! Finish creating your account.',
                'showPrefix'    => true,
            ],
            'resetPass' => [
                'subject'   => 'Reset your Password'
            ],
            'emailChange'   => [
                'subject'   => 'Successfully Changed Email'
            ],
            'passwordChange'    => [
                'subject'   => 'Successfully Changed Password',
            ]
        ]
    ];
}
/*
 * EXTEND WITH:
 *      {string} $message: email content
*       {WP_User} $user: user
 * apply_filters
 *      jvbNewUserEmail         ->  New user email content
 *          add_filter('jvbNewUserEmail', 'customFunction', 10, 2);
 *      jvbNewUserAdminEmail    ->  New User notification for admin
 *          add_filter('jvbNewUserAdminEmail', 'customFunction', 10, 2);
 *      jvbPasswordResetEmail   ->  Password Reset Email
 *          {string} $message: email content
 *          {string} $key
 *          {string} $user_login,
 *          {WP_User} $user_data
 *          add_filter('jvbPasswordResetEmail', 'customFunction', 10, 4);
 *      jvbEmailChangeRequestEmail      ->  Request for email change
 *          {string} $message
 *          {array} $oldUser
 *          {array} newUser
 *          add_filter('jvbEmailChangeRequestEmail', 'customFunction', 10, 3);
 *      jvbEmailChangedEmail    ->  Notification that email successfully changed
 *          {string} $message
 *          {string} $confirm_url
            add_filter('jvbEmailChangedEmail', 'customFunction', 10, 2);
 *      jvbPasswordChangeEmail  ->  Request for password change
 *          {string} $message
 *          {array} $oldUser
 *          {array} $newUser
 *          add_filter('jvbPasswordChangeEmail', 'customFunction', 10, 3);
 *      jvbPersonalDataExport   ->  Request for User Data
 *          {string} $message
 *          {string} $request_type
 *          {string} $confirmation_url
 *          {array} $emailData, from the original filter
 *          add_filter('jvbPersonalDataExport', 'customFunction', 10, 4);
 *      jvbPersonalDataExported ->  Notification that data is ready for download
 *          {string} $message
 *          {string} $downloadURL
 *          {string} $expiresAt
 *          {array} $emailData, from the original filter
 *          add_filter('jvbPersonalDataExported', 'customFunction', 10, );
 *
 */
 
add_filter('jvbNewUserEmail', 'altr_new_user_email', 10, 2);
function altr_new_user_email(string $message, WP_User $user):string
{
 
    $user_login = $user->user_login;
 
    // Only create the password key if the user can change their password
    $key = get_password_reset_key($user);
    if (!is_wp_error($key)) {
        $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
 
        $message = sprintf(
            '<p>Hey %s!</p>
            <p>Thanks for signing up for our referral program at Legacy.</p>
            <p><b>Login with your email: </b> %s</p>
            <p>To set your password and access your account, click the button below:</p>%s
            <p>Or copy and paste this link into your browser: %s</p>
            <p>Or go passwordless, and just sign on with a magic link.</p>
            <div class="divider"></div>
            <p>If you didn\'t create this account, just ignore this email and the link will expire.</p>',
            $user->display_name,
            $user->user_login,
            jvbMailButton($reset_url, 'Set Your Password'),
            jvbEmailLink($reset_url)
        );
    }
    return $message;
}
 
 
/*** EDMONTON INK VERSIONS: ***/
function eink_new_user_email(string $message, WP_User $user):string
{
    $user_login = $user->user_login;
 
    // Only create the password key if the user can change their password
    $key = get_password_reset_key($user);
    if (!is_wp_error($key)) {
        $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
 
        $message = sprintf('<p>Hey %s!</p>', $user->first_name);
        $message .= '<p>Thanks for joining Edmonton\'s tattoo scene. Here\'s your login information:</p>';
        $message .= sprintf('<p><strong>Username:</strong> %s</p>', $user_login);
        $message .= '<p>To set your password and access your account, click the button below:</p>';
        $message .= sprintf('<p style="text-align: center;"><a href="%s" class="button">Set Your Password</a></p>', $reset_url);
        $message .= '<p>Or copy and paste this link into your browser:</p>';
        $message .= sprintf('<p style="user-select:all;">%s</p>', $reset_url);
        $message .= '<p>This link will expire in 24 hours, for security reasons.</p>';
        if (in_array('jvb_artist', array_values($user->roles))) {
            $message .= '<div class="divider"></div>';
            $message .= '<h3>NOTE:</h3>
                    <p>Once you set your password, you\'ll have access to your custom dashboard where you can:</p>
                    <ul>
                        <li>Manage your profile information</li>
                        <li>Upload tattoos/piercings, and artwork</li>
                    </ul>
                    <p>Nothing will be published until you\'ve been approved by 3 already approved artists, or the admin.</p>
                    <p>Admins check every day or three, but, if you are in a rush, you can contact us directly by replying to this email, or texting us at 825-925-9916.</p>';
        } elseif (in_array('jvb_partner', array_values($user->roles))) {
            $message .= '<div class="divider"></div>';
            $message .= '<h3>NOTE:</h3>
                    <p>Once you set your password, you\'ll have access to your custom dashboard where you can:</p>
                    <ul>
                        <li>Manage your profile information</li>
                        <li>Create offers for enthusiasts or partners or both</li>
                    </ul>
                    <p>Nothing will be published until you\'ve been approved by the admin.</p>
                    <p>Admins check every day or three, but, if you are in a rush, you can contact us directly by replying to this email, or texting us at 825-925-9916.</p>
                    <p><strong>Note:</strong>Even after approval by admin, your ability to publish depends on your karmic standing by artists. Artists each have a vote they can cast (UP or DOWN) - if your karmic score dips too far in the negative, you account is subject to reconsideration or even a ban.</p>';
        }
        $message .= '<div class="divider"></div>';
 
 
        $message .= '<p>If you didn\'t create this account, please ignore this email and the link will expire.</p>';
        $message .= sprintf('<p>Ink on, %s</p>', $user->first_name);
    }
 
    return $message;
}
 
function eink_new_user_admin_email(string $message, WP_User $user):string
{
    $message .= sprintf(
        '<p><strong>Role:</strong> %s</p>',
        str_replace(BASE, '', array_values($user->roles)[0])
    );
    return $message;
}
function eink_password_reset_email(string $message, string $user_login, WP_User $user, string $resetUrl):string
{
    return sprintf(
        '<p>Hi bud,</p>
            <p>We received a request to reset the password for an account associated with this email:</p>
            <p><strong>Username:</strong> %s</p>
            <p>If you didn\'t make this request, you can safely ignore this email and nothing will happen to your account.</p>
            <p>To reset your password, click the button below:</p>
            %s
            <p>Or copy and paste this link into your browser:</p>
            %s
            <div class="divider"></div>
            <p>This password reset link is only valid for 24 hours.</p>',
        $user_login,
        jvbMailButton($resetUrl,'Reset Password'),
        jvbEmailLink($resetUrl)
    );
}
 
function eink_email_change_request_email(string $message, array $oldUser, array $newUser)
{
    return sprintf(
        '<p>Hi %s,</p>
        <p>Ideally you already know this: someone asked to change your email, and here we are.</p>
        <p><strong>Old Email:</strong> %s</p>
        <p><strong>New Email:</strong> %s</p>
        <div class="divider"></div>
        <p>If this is news to you, or you did not request this - please contact us immediately. You can <a href="sms:+18258239916">text us</a> or reply to this email."></a></p>
        %s',
        $newUser['first_name'],
        $oldUser['user_email'],
        $newUser['user_email'],
        jvbMailButton(wp_login_url(), 'Log In To Your Account')
    );
}
 
function eink_email_changed_email(string $message, string $confirmURL):string
{
    return sprintf(
        '<p>Hey human,</p>
            <p>Seems you want to change the email associated with your account.</p>
            <p>If you really want this, please confirm this change by clicking the button below:</p>
            %s
            <p>Or copy and paste this link into your browser:</p>
            %s',
        jvbMailButton($confirmURL, 'Confirm this Email'),
        jvbEmailLink($confirmURL)
    );
}
 
function eink_password_changed_email(string $message, array $oldUser, array $newUser):string
{
    return sprintf(
        '<p>Hey bud,</p>
            <p>This is a confirmation email to let you know your password has successfully been changed.</p>
            <p>Ideally, you\'re expecting this email. You wanted to change your password, and this is to let you know that it\'s definitely updated.</p>
            <p>If you\'re not expecting this email, and did not change your password - please <strong>contact us immediately</strong></p>
            <p>You can <a href="sms:+18259257398">text us</a>, or reply to this email.</p>
            %s',
        jvbMailButton(wp_login_url(), 'Log In to Your Account')
    );
}
 
function eink_personal_data_export(string $message, string $requestType, string $confirmURL, array $emailData):string
{
    switch ($requestType) {
        case 'export_personal_data':
            $request_name = 'Export Personal Data';
            break;
        case 'remove_personal_data':
            $request_name = 'Erase Personal Data';
            break;
        default:
            $request_name = 'Data Request';
    }
    return sprintf(
        '<p>Hi privacy enthusiast,</p>
            <p>You\'re receiving this email because a request has been made to <strong>%s</strong></p>
            <p>If you\'re the one who made this request, you can confirm it by clicking the button below:</p>
            %s
            <p>Or copy and paste this link into your browser:</p>
            %s',
        $request_name,
        jvbMailButton($confirmURL, 'Confirm'),
        jvbEmailLink($confirmURL)
    );
}
 
function eink_personal_data_exported_email(string $message, string $downloadURL, string $expiresAt, array $emailData):string
{
    return sprintf(
        '<p>Hi again,</p>
            <p>You\'re receiving this email because you requested an export of your personal data.</p>
            <p>You can download your personal data by clicking the button below:</p>
            %s
            <p>Or you can copy and paste this link into your browser:</p>
            %s
            <div class="divider"></div>
            <p><strong>Important:</strong> For privacy and security, this link will expire at %s.</p>',
        jvbMailButton($downloadURL, 'Download Your Data'),
        jvbEmailLink($downloadURL),
        $expiresAt
    );
}