Skip to content

Commit 7189c05

Browse files
authored
Fixes #98 (#114)
1 parent 5fe5c0a commit 7189c05

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,8 @@ public function metabox_form_fields() {
444444
* Meta box callback for submit email meta box
445445
*/
446446
public function metabox_submit_email( $post ) {
447-
// get post meta
448447
$meta = get_post_meta( $post->ID );
449-
$email_enabled = isset( $meta['_wplf_email_copy_enabled'] ) ? $meta['_wplf_email_copy_enabled'][0] : true;
448+
$email_enabled = ! empty( $meta['_wplf_email_copy_enabled'] ) ? (int) $meta['_wplf_email_copy_enabled'][0] : 0;
450449
$email_copy_to = isset( $meta['_wplf_email_copy_to'] ) ? $meta['_wplf_email_copy_to'][0] : '';
451450
$email_copy_from = isset( $meta['_wplf_email_copy_from'] ) ? $meta['_wplf_email_copy_from'][0] : '';
452451
$email_copy_from_address = isset( $meta['_wplf_email_copy_from_address'] ) ? $meta['_wplf_email_copy_from_address'][0] : '';
@@ -739,7 +738,7 @@ public function save_cpt( $post_id ) {
739738
if ( isset( $_POST['wplf_email_copy_enabled'] ) ) {
740739
update_post_meta( $post_id, '_wplf_email_copy_enabled', $_POST['wplf_email_copy_enabled'] === 'on' );
741740
} else {
742-
update_post_meta( $post_id, '_wplf_email_copy_enabled', false );
741+
update_post_meta( $post_id, '_wplf_email_copy_enabled', 0 );
743742
}
744743

745744
// save email copy

inc/wplf-form-actions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
add_action( 'wplf_post_validate_submission', 'wplf_send_email_copy', 20 );
44
function wplf_send_email_copy( $return, $submission_id = null ) {
5+
// Normally $submission_id is null, but when resending copies it isn't, which is why this check exists
56
if ( ! $submission_id ) {
67
$submission_id = $return->submission_id;
78
}
@@ -15,9 +16,9 @@ function wplf_send_email_copy( $return, $submission_id = null ) {
1516
$form_meta = get_post_meta( $form_id );
1617

1718
$referrer = esc_url_raw( ( isset( $submission_id ) ) ? get_post_meta( $submission_id, 'referrer', true ) : $_POST['referrer'] );
19+
$email_enabled = ! empty( $form_meta['_wplf_email_copy_enabled'] ) ? (int) $form_meta['_wplf_email_copy_enabled'][0] : false;
1820

19-
if ( ( isset( $form_meta['_wplf_email_copy_enabled'] ) && $form_meta['_wplf_email_copy_enabled'][0] ) || isset( $submission_id ) ) {
20-
21+
if ( $email_enabled ) {
2122
$to = isset( $form_meta['_wplf_email_copy_to'] ) ? $form_meta['_wplf_email_copy_to'][0] : get_option( 'admin_email' );
2223

2324
// translators: %submission-id% is replaced with submission id and %referrer% with referrer url

0 commit comments

Comments
 (0)