Skip to content

Commit 8ef0e0c

Browse files
k1sul1anttiviljami
authored andcommitted
Fix #69 (#70)
* Fix notices, fixes #69
1 parent 737f419 commit 8ef0e0c

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

inc/wplf-ajax.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ function wplf_ajax_submit_handler() {
6565
$attach_id = media_handle_upload( $key, 0, array(), array(
6666
'test_form' => false,
6767
) );
68-
add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
69-
add_post_meta( $post_id, $key . '_attachment', $attach_id );
68+
69+
if ( ! is_wp_error( $attach_id ) ) {
70+
add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
71+
add_post_meta( $post_id, $key . '_attachment', $attach_id );
72+
}
7073
}
7174

7275
// save email copy address to submission meta for later use

inc/wplf-form-actions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ function wplf_send_email_copy( $return, $submission_id = null ) {
7474
$subject = apply_filters( "wplf_{$form->post_name}_email_copy_subject", $subject );
7575
$content = apply_filters( "wplf_{$form->post_name}_email_copy_content", $content );
7676
$headers = apply_filters( "wplf_{$form->post_name}_email_copy_headers", $headers );
77-
$attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachment );
77+
$attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachments );
7878

7979
// form ID specific filters
8080
$to = apply_filters( "wplf_{$form->ID}_email_copy_to", $to );
8181
$subject = apply_filters( "wplf_{$form->ID}_email_copy_subject", $subject );
8282
$content = apply_filters( "wplf_{$form->ID}_email_copy_content", $content );
8383
$headers = apply_filters( "wplf_{$form->ID}_email_copy_headers", $headers );
84-
$attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachment );
84+
$attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachments );
8585

8686
wp_mail( $to, $subject, $content, $headers, $attachments );
8787
}

0 commit comments

Comments
 (0)