Extending Email Shortcodes to Allow Status To Be Displayed

Hi

Similar to what is requested here https://premium.wpmudev.org/forums/topic/confirmation-email-short-codes

How can I add a short code into the email template in the 'Settings' for confirmation message that will add the current STATUS as there does not currently appear to be an option?

I currently have

Kick Off Time: DATE_TIME<br>
Home Team: FIELD_HOMETEAM<br>
Away Team: FIELD_AWAYTEAM<br>
Age Group: FIELD_AGEGROUP<br>
Competition: FIELD_COMPETITION<br>
Location: FIELD_LOCATIONOFGROUND<br>
Match Official Allocated: SERVICE_PROVIDER<br>

I would like to add the additional field of

Current Status: STATUS

So in effect it would look like this

Kick Off Time: DATE_TIME<br>
Home Team: FIELD_HOMETEAM<br>
Away Team: FIELD_AWAYTEAM<br>
Age Group: FIELD_AGEGROUP<br>
Competition: FIELD_COMPETITION<br>
Location: FIELD_LOCATIONOFGROUND<br>
Match Official Allocated: SERVICE_PROVIDER<br>
Current Status: STATUS<br>

How do i get this short code to work please?

Thanks

Wayne

  • Vaughan
    • Support/SLS MockingJay

    Hi @wayne,

    Using the method posted by Jack in the thread you linked to.

    function my_app_expand_status ($msg, $app) {
    if (empty($_POST['status']) return $msg;
    return preg_replace('/STATUS/', $_POST['status'], $msg);
    }
    add_filter('app_confirmation_message', 'my_app_expand_status', 10, 2);
    add_filter('app_notification_message', 'my_app_expand_status', 10, 2);
    add_filter('app_reminder_message', 'my_app_expand_status', 10, 2);

    I haven't tested this, but hopefully that should work.

    Hope this helps

  • Wayne
    • The Incredible Code Injector

    Hi @Vaughan

    Sorry if I add this to the functions.php file of my theme it gives a blank white screen;

    /**
     * Allow status in email template Appointments
     */
    function my_app_expand_status ($msg, $app) {
    if (empty($_POST['status']) return $msg;
    return preg_replace('/STATUS/', $_POST['status'], $msg);
    }
    add_filter('app_confirmation_message', 'my_app_expand_status', 10, 2);
    add_filter('app_notification_message', 'my_app_expand_status', 10, 2);
    add_filter('app_reminder_message', 'my_app_expand_status', 10, 2);

    Regards

    Wayne

  • Wayne
    • The Incredible Code Injector

    Hi @Vaughan

    Just done some further testing on this - really strange and we are obviously missing something.

    The short code STATUS is in the email template and if I update an appointment from the admin area and check the "(Re)send confirmation email" option and click save changes - the email sends and the word STATUS is replaced with the status of confirmed or pending etc.

    If the appointment is pending and the service provider goes to the front end of the site and checks the 'confirm' option - the status updates to Confirmed as it should and the same confirmation email is sent however this time the word STATUS simply says "STATUS" - it is not translating it to the actual status.

    Regards

    Wayne

  • Vaughan
    • Support/SLS MockingJay

    Hi @wayne,

    As that thread is a lot more detailed, and the developer is also working with you on that thread, it would be better to keep this in the same thread, I'll mark this thread as resolved, and let saurabh know of your response there.

    Thanks

  • Saurabh
    • New Recruit

    Hi @Wayne,

    The code that @Vaughan has provided wouldn't accomodate the changes made for the custom email flow in the other thread. Updating it, as follows, solves the issue:

    /**
     * Allow status in email template Appointments
     */
    function my_app_expand_status ($msg, $app) {
    $app = (object) $app;
    if (empty($app->status)) return $msg;
    return preg_replace('/STATUS/', $app->status, $msg);
    }
    add_filter('app_confirmation_message', 'my_app_expand_status', 10, 2);
    add_filter('app_notification_message', 'my_app_expand_status', 10, 2);
    add_filter('app_reminder_message', 'my_app_expand_status', 10, 2);

    Best

    Saurabh

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.