Startseite › Toolset Professional Support › [Gelöst] Need help to define placeholders
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Verwandte Dokumentation:
Dieses Thema enthält 16 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von Minesh vor 5 Jahren, 3 Monaten.
Assistiert von: Minesh.
Hello,
I have created a form and wants to define a notification.
As I need to retrieve some custom fields from the form, I have created a snippet to define custom placeholders.
Here is thesnippet :
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification', 10, 1); add_filter('cred_body_notification_codes', 'custom_generic_field_notification', 10, 1); function custom_generic_field_notification( $defaultPlaceHolders ) { $newPlaceHolders = array( '%%SALLE_NOM%%' => $_REQUEST['salle-nom'], '%%SALLE_ADRESSE%%' => $_REQUEST['salle-adresse'], '%%SALLE_COMPLEMENT%%' => $_REQUEST['salle-complement'], '%%SALLE_TELEPHONE%%' => $_REQUEST['salle-telephone'], '%%SALLE_HORAIRES%%' => $_REQUEST['salle-horaires'], '%%STAGE_DEBUT%%' => $_REQUEST['stage-date-debut'], '%%STAGE_FIN%%' => $_REQUEST['stage-date-fin'] ); return array_merge($defaultPlaceHolders, $newPlaceHolders );
And here is the code inserted inside the Form :
[cred_generic_field field='salle-nom' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[wpv-post-title item="@salle-product.parent"]" } [/cred_generic_field] [cred_generic_field field='salle-adresse' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='adresse-de-la-salle' item='@salle-product.parent'][/types]" } [/cred_generic_field] [cred_generic_field field='salle-complement' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='complement-adresse-salle' item='@salle-product.parent'][/types]" } [/cred_generic_field] [cred_generic_field field='salle-telephone' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='telephone-de-la-salle' item='@salle-product.parent'][/types]" } [/cred_generic_field] [cred_generic_field field='salle-horaires' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='horaires-de-la-salle' item='@salle-product.parent'][/types]" } [/cred_generic_field] [cred_generic_field field='stage-date-debut' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='date-debut-stage' style='text' format='j F Y'][/types]" } [/cred_generic_field] [cred_generic_field field='stage-date-fin' type='textfield' class='' urlparam=''] { "required":0, "validate_format":0, "default":"[types field='date-fin-de-stage' style='text' format='j F Y'][/types]" } [/cred_generic_field]
The result of this is that the placeholders are not displayed inside the notification email. Is there something wrong with my code?
Regards
Pat
Hello. Thank you for contacting the Toolset support.
First of all - After checking to debug information you shared with us, I found that you are using outdated Toolset plugins. We always recommend running your site with latest stable release plugin version.
*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
Can you please update ALL Toolset plugins first and check if that help you to resolve your issue. If no, please share problem URL and access details.
I have set the next reply to private which means only you and I have access to it.
More info:
=> https://toolset.com/documentation/user-guides/how-to-use-custom-placeholders-in-cred-notifications/
Hi Minesh,
I have updated all plugins and the issue is still there.
Sorry but there was no private answer.
Could you turn it on for my next reply?
Thanks
Pat
Sure.
I have set the next reply to private which means only you and I have access to it.
Hi Minesh,
It seems my last answer is not private. I don't understand why but all private info are seenable by anybody !!!
I have changed the password and need to give you the new one in a secure way.
Please delete (or make private my last answer and allow a real private message for the new password.
Regards
Pat
I make last reply as private. I dont know what's happening here.
Again, I have set the next reply to private which means only you and I have access to it. If you do not see next reply as private, please edit the password in previous reply.
ok - I see now why its not working.
You are using the $_REQUEST to grab the value of your fields but when you are completing order from backend those $_REQUEST fields will not be available as it will be only available when you post/submit the form.
$newPlaceHolders = array( '%%SALLE_NOM%%' => $_REQUEST['salle-nom'], '%%SALLE_ADRESSE%%' => $_REQUEST['salle-adresse'], '%%SALLE_COMPLEMENT%%' => $_REQUEST['salle-complement'], '%%SALLE_TELEPHONE%%' => $_REQUEST['salle-telephone'], '%%SALLE_HORAIRES%%' => $_REQUEST['salle-horaires'], '%%STAGE_DEBUT%%' => $_REQUEST['stage-date-debut'], '%%STAGE_FIN%%' => $_REQUEST['stage-date-fin'] );
That is why the above placeholders are not working. If you will try to add some static text to your place holder, for example:
'%%SALLE_NOM%%' => "THIS IS DUMMY NAME",
And save your snippet and place the order and complete the order you will see the placeholder is working.
Hi Minesh,
Thanks for the info.
Does that means that this is not possible to retrieve the custom fields content when the notification comes after the payment?
How can I manage to have this info as I need to sent a confirmation mail to the user including those fields content?
Do I need to move from REQUEST to a get_postmeta() in the snippet? If yes, how could I be sure to find the right post to extract the related postmeta?
Regards
Pat
I want to run a test to check if there is a way to get post ID (order ID), can you please give me full grant as when I try to edit the post form (ID 113) it does not allow me. Maybe you are editing there.
Minesh,
I have disconnected to all pages / posts so you should be able to access all needed info.
Regards
Pat
Ok - I checked and there is no way to get the order ID.
I see you have added the following thing. Is that a current loggedin user ID information or specific user information.
$newPlaceHolders = array( '%%SALLE_NOM%%' => $_REQUEST['salle-nom'], '%%SALLE_ADRESSE%%' => $_REQUEST['salle-adresse'], '%%SALLE_COMPLEMENT%%' => $_REQUEST['salle-complement'], '%%SALLE_TELEPHONE%%' => $_REQUEST['salle-telephone'], '%%SALLE_HORAIRES%%' => $_REQUEST['salle-horaires'], '%%STAGE_DEBUT%%' => $_REQUEST['stage-date-debut'], '%%STAGE_FIN%%' => $_REQUEST['stage-date-fin'] );
You need to find a way to get those values using custom programming. As there is no way to achieve those field values using $REQUEST.
Hi Minesh,
In fact, those data are coming from :
1. The product chosen (the form is inserted inside the single product page). The 2 info relative to the product are 'stage-date-debut' and 'stage-date-fin'
2. The posttype "salle" which is in relationship with the product for all other custom fields.
So, these data are not linked to a user but to a product.
Regards
Pat
Ok - thanks for sharing this information. But there is no way to get the product ID in the backend while you complete the order from wp-admin. I already checked this and you need to find a way to get the product ID within the "cred_body_notification_codes" hook when you mark order as complete.
If you need custom programming for your project, please feel free to contact our certified partners:
=> https://toolset.com/contractors/
Do you mean that if the product is paid thanks to PayPal for example, then the info relative to the placehoder will be available? When the site will be in production, that will be the standard way of working (the manual validation in the admin will be replaced by another form that will be published as soon as validated).
Regards
Pat
no - I mean that there is no way to get the product information within the "cred_body_notification_codes" especially when you are marking the product publish from backend.
If its paypal and automatically the order status is going to set to completed with your production site, the code you are using should work or you need to make a test.
Also, there are number of Toolset Form Commerce hooks available - if you would like to check.
https://toolset.com/documentation/programmer-reference/cred-commerce-api/