From e9967fa22781d922ba4eb8fb44fe72d200ac4b14 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 10 Nov 2025 21:04:10 +0000
Subject: [PATCH] =IconsManager.php update
---
inc/rest/routes/Invitations.php | 57 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/inc/rest/routes/Invitations.php b/inc/rest/routes/Invitations.php
index 1372cb4..8758609 100644
--- a/inc/rest/routes/Invitations.php
+++ b/inc/rest/routes/Invitations.php
@@ -48,20 +48,8 @@
// Add hooks for processing accepted invitations
add_action('user_register', [$this, 'checkInvitation'], 10, 1);
- add_action('jvbLoginManagerInit', function($loginManager) {
- $loginManager->registerTokenHandler('invite', function($token, $email, $user_id) {
- JVB()->routes('invites')->acceptInvitation($token, $email, $user_id);
- });
- $loginManager->registerMessageHandler('invitation',
- function() {
- return '<h2>You\'ve been invited!</h2><p>Create your account to accept.</p>';
- },
- function() {
- return isset($_GET['invite']);
- }
- );
- });
+ add_filter('jvbLoginLabels', [$this, 'modifyLoginLabels'], 10, 2);
@@ -1361,4 +1349,47 @@
];
}
}
+
+ public function modifyLoginLabels(array $labels, array $get_params): array
+ {
+ // Only modify if invitation params present
+ if (!array_key_exists('invite', $get_params) || !array_key_exists('email', $get_params)) {
+ return $labels;
+ }
+ $email = sanitize_email($get_params['email']);
+ $token = sanitize_text_field($get_params['invite']);
+ $user = email_exists($email);
+ if (!$user) {
+ return $labels;
+ }
+ $role = jvbUserRole($user);
+ // Get invitation data
+ $data = $this->verifyInvitation(
+ $token,
+ $email,
+ $role,
+ );
+
+ if (!$data) {
+ return $labels;
+ }
+
+ // Build custom message
+ $inviters = json_decode($data->inviters, true);
+ $name = $data->name;
+ $names = array_map(function($inviter) {
+ $artist = jvbContentFromUser((int)$inviter['user_id']);
+ return $artist['name'] ?: $artist['display_name'];
+ }, $inviters);
+
+ $message = count($names) > 1
+ ? 'are already here, and have invited you to join in!'
+ : ' is already here, and invited you to join in!';
+
+ // Modify labels
+ $labels['title'] = 'Join the Scene, ' . $data->name;
+ $labels['description'] = [jvbCommaList($names) . ' ' . $message];
+
+ return $labels;
+ }
}
--
Gitblit v1.10.0