<?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>  — ♡ the edmonton.ink crew</p>',
|
'footer' => [
|
'<p>© ' . 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
|
);
|
}
|