Hello, all. I’m trying to create an email using data from a Participants Database database triggered from a Caldera Form. I’m almost there but can’t seem to use the trigger values in the php code:
global $wpdb;
global $wpdb;
$email = $wpdb->get_var(“SELECT email FROM jtparticipants_database WHERE id=$trigger.fields.postid”);
return $email;
What is the appropriate way to do this? postid is the slug for a hidden field in the Caldera Form. Thanks
- John asked 4 years ago
- You must login to post comments
First of all, in the Execute PHP block you may use only PHP code. You may not use $trigger.fields.postid
because it’s not a valid PHP syntax. That’s why your first version didn’t work the way you expected.
The correct syntax is $trigger['fields']['postid']
- Gregory answered 4 years ago
-
Thank you. Yes, that I figured out eventually. However, I still have the strange behavior I mention below. But it is working now that I moved the field.
- You must login to post comments
This is very strange. The problem seemed to be because the hidden field was after the submit button on the form. When I moved it above the button, it worked (with the correct syntax):
global $wpdb;
$postid = $trigger[‘fields’][‘postid’];
$email = $wpdb->get_var(“SELECT email FROM jtparticipants_database WHERE id=$postid”);
return $email;
- John answered 4 years ago
- You must login to post comments
Please login first to submit.