Forum Replies Created
- AuthorPosts
- March 20, 2024 at 12:36 am in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36605
fbxac
ParticipantHi,
Thanks so much for the update. This works!
fbxac
ParticipantThis code did work. However, when trying to modify coding to work with different variables and situations, its not working.
For example, id like to do the following:
Radio Buttons (each is linked with a specific email template)
Approved
Rejected
WaitlistedRadio Button
Server
Bartender
CashierWhen the user submits for Server, I want them to receive a specific notification email for approved, rejected, waitlisted
When the user submits for Bartender, I want them to receive a specific notification email for approved, rejected, waitlisted
So basically
Server – Approved – Specific email contents for approval
Bartender – Approved – Specific email contents for approvalHow can I do this? I think you guys should definitely make this a feature in the software instead of coding for each form. This is a powerful feature that allows managing custom communication for different situations.
- This reply was modified 1 year, 2 months ago by
fbxac.
fbxac
ParticipantResolved the issue for anyone who needs help. Here is the modified code:
<?php
/*
* Plugin Name: Quform Approval Automation
* Description: Send auto notifications when marking applications as Approve, Reject or Waitlist
* Version: 1.0
*/// Paste in your custom code below
add_filter(‘quform_entry_post_set_entry_id_1’, function (array $result, Quform_Form $form) {
// Look up old field value
global $wpdb;
$elementId = ‘1_78’;list(, $eid) = explode(‘_’, $elementId);
$oldValue = $wpdb->get_var(
$wpdb->prepare(
“SELECT value
FROM {$wpdb->prefix}quform_entry_data
WHERE entry_id = %d
AND element_id = %d”,
$form->getEntryId(),
$eid
)
);$newValue = $form->getValue(“quform_$elementId”);
if ($oldValue !== $newValue) {
// Value has changed, determine which notification to send
$notificationId = ”;
switch ($newValue) {
case ‘Approved’:
$notificationId = ‘1_3’; // Replace ‘1_3’ with the ID for the Approved notification
break;
case ‘Reject’:
$notificationId = ‘1_4’; // Replace ‘1_4’ with the ID for the Reject notification
break;
case ‘Waitlist’:
$notificationId = ‘1_5’; // Replace ‘1_5’ with the ID for the Waitlist notification
break;
// Add more cases as needed for additional options
}if ($notificationId) {
// Send notification if a valid notification ID is found
foreach ($form->getNotifications() as $notification) {
if ($notification->getIdentifier() === $notificationId) {
$notification->send();
break; // Stop iterating once notification is sent
}
}
}
}return $result;
}, 10, 2);fbxac
ParticipantHi,
Thanks for the update. This worked, however, it only worked for 1 configured option. I am choosing a radio option with the following:
Approve
Reject
WaitlistBelow is my code. Am I supposed to duplicate the code 3x (one for each class ie: Approve, Reject, Waitlist)
<?php/*
* Plugin Name: Quform Approval Automation
* Description: Send auto notifications when marking applications as Approve, Reject or Waitlist
* Version: 1.0
*/// Paste in your custom code below
##APPROVAL EMAIL
add_filter('quform_entry_post_set_entry_id_1', function (array $result, Quform_Form $form) {
// Look up old field value
global $wpdb;
$elementId = '1_78';
$notificationId = '1_3';list(, $eid) = explode('_', $elementId);
$value = $wpdb->get_var(
$wpdb->prepare(
"SELECT value
FROM {$wpdb->prefix}quform_entry_data
WHERE entry_id = %d
AND element_id = %d",
$form->getEntryId(),
$eid
)
);if ($value != $form->getValue("quform_$elementId")) {
// Value has changed, send notification
foreach ($form->getNotifications() as $notification) {
if ($notification->getIdentifier() == $notificationId) {
$notification->send();
}
}
}return $result;
}, 10, 2);##REJECTED EMAIL
add_filter('quform_entry_post_set_entry_id_1', function (array $result, Quform_Form $form) {
// Look up old field value
global $wpdb;
$elementId = '1_78';
$notificationId = '1_4';list(, $eid) = explode('_', $elementId);
$value = $wpdb->get_var(
$wpdb->prepare(
"SELECT value
FROM {$wpdb->prefix}quform_entry_data
WHERE entry_id = %d
AND element_id = %d",
$form->getEntryId(),
$eid
)
);if ($value != $form->getValue("quform_$elementId")) {
// Value has changed, send notification
foreach ($form->getNotifications() as $notification) {
if ($notification->getIdentifier() == $notificationId) {
$notification->send();
}
}
}return $result;
}, 10, 2);##WAITLIST EMAIL
add_filter('quform_entry_post_set_entry_id_1', function (array $result, Quform_Form $form) {
// Look up old field value
global $wpdb;
$elementId = '1_78';
$notificationId = '1_5';list(, $eid) = explode('_', $elementId);
$value = $wpdb->get_var(
$wpdb->prepare(
"SELECT value
FROM {$wpdb->prefix}quform_entry_data
WHERE entry_id = %d
AND element_id = %d",
$form->getEntryId(),
$eid
)
);if ($value != $form->getValue("quform_$elementId")) {
// Value has changed, send notification
foreach ($form->getNotifications() as $notification) {
if ($notification->getIdentifier() == $notificationId) {
$notification->send();
}
}
}return $result;
}, 10, 2);March 14, 2024 at 11:33 am in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36585fbxac
ParticipantHello,
Email sent!
March 14, 2024 at 11:04 am in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36583fbxac
ParticipantAlso, are you able to help on the other question that was sent a while ago. i responded to an inquiry in regards to triggering emails when changing application information from admin side.
For example,
In the same form we’re speaking about, I created a hidden option that says “application status” that is for admin only. The options are Approve, Reject, Waitlist. When I modify the application from admin side, id like for it to trigger the email for “approved application” or any of the emails for each chosen option. When I modify and choose an option like “Approve”, email notifications are not sent/triggered
March 14, 2024 at 11:00 am in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36582fbxac
ParticipantHello,
Sure. Sent in feedback form
March 14, 2024 at 10:42 am in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36579fbxac
ParticipantHi Ally,
Thanks for the update. Conditions arent turned on for the select menu. The only way I can make it work was if I disabled “”Please select” option”. When this option was enabled, I chose an option in the drop down and it still didn’t capture it even though it was selected instead of the “Please select” drop down option.
The first name configuration worked, thank you.
Please advise, thanks.
fbxac
ParticipantHello,
Just had this issue myself. Are you able to send the code and or process to do this here?
March 13, 2024 at 11:51 pm in reply to: Shortcode question & Issue : “Select Menu” element in system and emails #36573 - This reply was modified 1 year, 2 months ago by
- AuthorPosts