Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • fbxac
    Participant

    Hi,

    Thanks so much for the update. This works!

    in reply to: Send notification email when changing in backend #36589
    fbxac
    Participant

    This 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
    Waitlisted

    Radio Button
    Server
    Bartender
    Cashier

    When 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 approval

    How 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.
    in reply to: Send notification email when changing in backend #36587
    fbxac
    Participant

    Resolved 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);

    in reply to: Send notification email when changing in backend #36586
    fbxac
    Participant

    Hi,

    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
    Waitlist

    Below 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);

    fbxac
    Participant

    Hello,

    Email sent!

    fbxac
    Participant

    Also, 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

    fbxac
    Participant

    Hello,

    Sure. Sent in feedback form

    fbxac
    Participant

    Hi 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.

    in reply to: Send notification email when changing in backend #36575
    fbxac
    Participant

    Hello,

    Just had this issue myself. Are you able to send the code and or process to do this here?

    fbxac
    Participant

    Attached image

    Attachments:
    You must be logged in to view attached files.
Viewing 10 posts - 1 through 10 (of 10 total)
Be inspired. © 2025 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy