Skip to content

Commit 780f59b

Browse files
timiwahalahtiAntti Kuosmanen
authored andcommitted
Add referrer id to hidden fields and filters for email (#27)
* Added referrer ID to form hidden fields * Add filters for email * Add filters for email headers and attachments
1 parent acd54cb commit 780f59b

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ function wplf_form( $id , $content = '', $xclass = '' ) {
456456
<form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>" <?php echo $multipart; ?>>
457457
<?php echo apply_filters( 'wplf_form', $content ); ?>
458458
<input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
459+
<input type="hidden" name="_referrer_id" value="<?php esc_attr_e( get_the_id() ) ?>">
459460
<input type="hidden" name="_form_id" value="<?php esc_attr_e( $id ); ?>">
460461
</form>
461462
<?php

inc/wplf-form-actions.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ function wplf_send_email_copy( $return ) {
1818
if( isset($form_meta['_wplf_email_copy_enabled']) && $form_meta['_wplf_email_copy_enabled'][0] ) {
1919
$to = isset($form_meta['_wplf_email_copy_to']) ? $form_meta['_wplf_email_copy_to'][0] : get_option( 'admin_email' );
2020
$subject = wp_sprintf( __('New submission from %s', 'wp-libre-form'), $referrer );
21-
$content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id ) . "\n\n";
21+
$content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id );
22+
$content = apply_filters( 'wplf_email_copy_content_start', $content, $form_title, $form_id ). "\n\n";
23+
2224
foreach( $_POST as $key => $value ) {
2325
if( '_' === $key[0] ) {
2426
continue;
2527
}
2628
$content .= esc_html( $key ) . ': ' . esc_html( print_r( $value, true ) ) . "\n";
2729
}
28-
wp_mail( $to, $subject, $content );
30+
31+
wp_mail(
32+
apply_filters( 'wplf_email_copy_to', $to ),
33+
apply_filters( 'wplf_email_copy_subject', $subject ),
34+
apply_filters( 'wplf_email_copy_content', $content ),
35+
apply_filters( 'wplf_email_copy_headers', '' ),
36+
apply_filters( 'wplf_email_copy_attachments', array() )
37+
);
2938
}
3039
}
31-

0 commit comments

Comments
 (0)