Skip Navigation

[Resolved] Form notifications include printed types shortcodes

This thread is resolved. Here is a description of the problem and solution.

Problem:
Form notifications that were working now output types shortcodes rather than resolving them to the field values.

Solution:
We had two open issues related to this, which will shortly be resolved, but which include patches in the linked errata.

Relevant Documentation:
https://toolset.com/errata/types-shortcodes-used-as-id-attribute-values-are-not-executed-in-forms-notifications/
https://toolset.com/errata/types-shortcodes-are-not-expanding-in-toolset-forms-notifications/

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by PaulS4783 6 years ago.

Assisted by: Nigel.

Author
Posts
#1149133

I need to re-open this ticket.

https://toolset.com/forums/topic/how-to-send-an-automatic-email-when-a-custom-field-is-updated-via-dashboard/page/3/

I HAD a working site as per the following workflow for Types 3.0.7
hidden link

But at some time in the last 3 months, an update to either CRED or TYPES seems to have broken the notification emails.
They now are printing the shortcodes, which previously worked.

Shipment Code: MOXG78912NW22

Customer Name: [types id=”1270” field=’customer-name’][/types]

Shipment Stage: [types field=’shipment-stage’][/types]
Point of Departure: [types id=”1270” field=’point-of-departure’][/types]
Point of Arrival: [types id=”1270” field=’point-of-arrival’][/types]
Estimated Delivery Date: [types field=’delivery-date-estimated-actual’ style=’text’ format=’Y-m-d’][/types]
Description of Goods: [types id=”1270” field=’description-of-goods’][/types]

Our shipment delivery stages.

A. Order Received / ご注文承りました
B. Being Prepared / 準備中
C. Ocean Transit / 海上輸送
D. Pending Customs / 保留中の習慣
E. Destination Warehouse / 行き先倉庫
F. Inland Transport / 内陸輸送
G. Delivered / 届いた

NOTE:

//ToolSet email notification code snippet below
//To send out email to a customer in correct language when shipment status is changed
/*
 * Custom shortcode trid to provide translated post id if required
 */
add_shortcode( 'trid', function( $atts ){
 
    $pid = $atts['pid']; // post id of post that triggers notification
 
    // Get the preferred language
    $lang = get_post_meta( $pid, 'wpcf-customer-language', true );
 
    $trid = apply_filters( 'wpml_object_id', $pid, 'shipment', TRUE, $lang );
 
    return $trid;
 
});

THIS IS A DEV SITE SO FEEL FREE TO EDIT !

#1149156

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Paul

This is known and will be fixed in Types 3.2: https://toolset.com/errata/types-shortcodes-are-not-expanding-in-toolset-forms-notifications/

There is a patch available in that erratum, do you want to try that and verify that it resolves the problem?

#1149464

OK. Lets try the patch.

Also, any advice on when vers 3.2 will be ready?

#1149653

I used the patch files.
It's now working in the sense that I no longer receive Short Codes in the email notification.

HOWEVER...
The notification is absent those fields which are translated.
(Customer Name, Point of Departure, Point of Arrival, Description of Goods).

See our previous discussion and custom functions code for identifying the Post ID as part of the shortcode.

Shipment Code: MOXG789126TST

Customer Name:

Shipment Stage: B. Being Prepared / 準備中
Point of Departure:
Point of Arrival:
Estimated Delivery Date: 2018-11-11
Description of Goods:

SO... when I remove the Post ID reference "nested shortcode" it works.

Shipment Code: MOXG789126TST

Customer Name: Trans Global Cars

Shipment Stage: C. Ocean Transit / 海上輸送
Point of Departure: Kobe
Point of Arrival: Dubai
Estimated Delivery Date: 2018-11-11
Description of Goods:

5 Passenger Cars

To be clear, what I did was change this:

p><strong>Shipment Code: [wpv-post-title]</strong></p>
<p><strong>Customer Name: </strong>[types id="[trid pid='%%POST_ID%%']" field='customer-name'][/types]</p>
<p><strong>Shipment Stage: </strong>[types field='shipment-stage'][/types]<br />
<strong>Point of Departure: </strong>[types id="[trid pid='%%POST_ID%%']" field='point-of-departure'][/types]<br />
<strong>Point of Arrival: </strong>[types id="[trid pid='%%POST_ID%%']" field='point-of-arrival'][/types]<br />
<strong>Estimated Delivery Date: </strong>[types field='delivery-date-estimated-actual' style='text' format='Y-m-d'][/types]<br />
<strong>Description of Goods: </strong>[types id="[trid pid='%%POST_ID%%']" field='description-of-goods'][/types]<br /></p>
<br>

to this:

<p><strong>Shipment Code: [wpv-post-title]</strong></p>
<p><strong>Customer Name: </strong>[types field='customer-name'][/types]</p>
<p><strong>Shipment Stage: </strong>[types field='shipment-stage'][/types]<br />
<strong>Point of Departure: </strong>[types field='point-of-departure'][/types]<br />
<strong>Point of Arrival: </strong>[types field='point-of-arrival'][/types]<br />
<strong>Estimated Delivery Date: </strong>[types field='delivery-date-estimated-actual' style='text' format='Y-m-d'][/types]<br />
<strong>Description of Goods: </strong>[types field='description-of-goods'][/types]<br /></p>
<br>

BUT .... It obviously returns us to the problem of the notification not identifying the correct language version.
When the "preferred language" is set to Japanese, I incorrectly get the default English custom fields even though translations of those fields exist.

出荷コード: MOXG789126TST

顧客名: Trans Global Cars

出荷段階: F. Inland Transport / 内陸輸送
出発点: Kobe
到着地点: Dubai
お届け予定日: 2018-11-11
商品の説明:

5 Passenger Cars

The "nested shortcode" Post ID previously solved that problem.

Can you advise?

#1149974

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry about this Paul.

I don't have the same test environments I had previously to work on this, so I'll need to set it up again.

(If I need to report to the devs that something is broken, I need to be able to do that on a clean test site rather than on your "dirty" production site, so that the problem is isolated.)

So I will first set up a fresh test site with the older plugin versions to see it working, then see what subsequent updates break this—bearing in mind there could be a problem with a WPML update or with Toolset updates.

Please bear with me while I recreate this set up.

#1150656

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Paul

I got my test site up and running with it working as it was in August, confirmed it doesn't currently work (including when the Types patch is applied that we discussed above), and then went back updating through the various plugin releases to identify the culprit.

It turns out that it was the last Forms update—to 2.1.2—and that we have recently published an errata about a related notifications issue.

This will be fixed in the next few days when we have a raft of plugin updates (ahead of WP 5.0 next week), but there is a solution described in this erratum if you want to apply that now: https://toolset.com/errata/types-shortcodes-used-as-id-attribute-values-are-not-executed-in-forms-notifications/

I tested that and having applied both the patches found it working as expected on my test site.

Please try that and let me know if you still see any problems.

#1150930

Thanks. I trust you.
If you are confident the Forms Plugin update will get us back on track, I can wait for that 😉

You can close the ticket (for now).