Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Send personalized emails from list field
- add_action( 'gform_after_submission_1', 'send_list_field_notifications', 10, 2 );
- function send_list_field_notifications( $entry, $form ) {
- $field_id = 19; // the id of the list field
- // get the $field object for the provided id
- $field = RGFormsModel::get_field( $form, $field_id );
- // check the field type as we only want the rest of the function to run if the field type is list
- if ( $field->get_input_type() != 'list' ) {
- return;
- }
- $list_values = rgar( $entry, $field_id );
- if ( empty( $list_values ) ) {
- return;
- }
- // setup the basic notification properties
- $notification = array(
- 'id' => 'list_field_notification',
- 'name' => 'list_field_notification',
- 'fromName' => '{Your Name (First):16.3} {Your Name (Last):16.6}',
- 'from' => '{Your Email Address:7}',
- 'subject' => 'Our Team ({Team Name:1}) Has Been Registered in The Reach Open Golf Tournament',
- );
- $message = 'Hey {firstname},<br><br>I just registered our team ({Team Name:1}) in the 2016 Reach Open Golf Tournament. Be sure to register as a member of our team by visiting the website at: http://thereachopen.org/register-with-a-team/. [gravityforms action="conditional" merge_tag="{Do You Wish To Pay For Your Entire Team Or Will Each Member Pay Individually:4}" condition="is" value="Pay For Entire Team"][gravityform action="conditional" merge_tag="{Buy Team Tee Buster & Mulligans:13.1}" condition="is" value="I would like to pay for my team\'s Tee Buster and Mulligans"]
- I have already paid our team registration costs of $500 as well as purchased a Tee Buster and Mulligan package for each of us, so you will only have to register as a member of our team.
- [/gravityform][/gravityforms][gravityforms action="conditional" merge_tag="{Do You Wish To Pay For Your Entire Team Or Will Each Member Pay Individually:4}" condition="is" value="Pay For Entire Team"][gravityform action="conditional" merge_tag="{Buy Team Tee Buster & Mulligans:13.1}" condition="isnot" value="I would like to pay for my team\'s Tee Buster and Mulligans"]
- I have already paid our team registration costs of $500. If you would like to purchas a Tee Buster and Mulligan package you can choose that from the registration form. So go ahead and register as a member of our team.
- [/gravityform][/gravityforms][gravityforms action="conditional" merge_tag="{Do You Wish To Pay For Your Entire Team Or Will Each Member Pay Individually:4}" condition="is" value="Pay For Entire Team"]When you register, you will need to pay your registration fee of $125. You may also purchase a Tee Buster and Mulligan package at that time.
- [/gravityforms]<br>
- <br>
- While you are registering, if you want to attend the dinner that evening, you can make your reservations and pay for that.<br>
- <br>
- You will be taken to PayPal to pay any additional fees after you click the submit button if you select "Pay Online". If you choose to mail in a check, you will be shown the mailing address to send the check to.<br>
- <br>
- [gravityforms action="conditional" merge_tag="{My Personal Note:17}" condition="isnot" value=""]
- P.S. {My Personal Note:17}
- [/gravityforms]';
- $first_name_col_key = rgars( $field->choices, "0/text" ); // first column
- $email_col_key = rgars( $field->choices, "2/text" ); // third column
- $list_values = unserialize( $list_values );
- foreach ( $list_values as $value ) {
- // get the emails for each row
- $email = rgar( $value, $email_col_key );
- if ( GFCommon::is_valid_email( $email ) ) {
- $notification['to'] = $email;
- $notification['message'] = str_replace( '{firstname}', rgar( $value, $first_name_col_key ), $message );
- GFCommon::send_notification( $notification, $form, $entry );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment