From 84490de519221c6bd5c4f877559d2788beb53a77 Mon Sep 17 00:00:00 2001 From: Arne Kamola Date: Mon, 3 Dec 2018 12:03:05 +0100 Subject: [PATCH] Fix for PHP notice error on custom field required check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP (with WordPress in development mode) shows a notice error on custom fields without a required flag: > Notice: Undefined index: _custom_field_1_required in […]/wordpress/wp-content/plugins/sendpress/classes/sc/class-sendpress-sc-forms.php on line 494 This fix provides a quick fix with a check, if the required flag exists in the options array. --- classes/sc/class-sendpress-sc-forms.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/sc/class-sendpress-sc-forms.php b/classes/sc/class-sendpress-sc-forms.php index 946d8a42..bb2866c3 100644 --- a/classes/sc/class-sendpress-sc-forms.php +++ b/classes/sc/class-sendpress-sc-forms.php @@ -491,9 +491,13 @@ private static function signup($options){ $label = $value['custom_field_label']; $required = false; - if(filter_var(($options['_custom_field_'.$value['id'].'_required'] === 'on'), FILTER_VALIDATE_BOOLEAN) ){ + if(array_key_exists('_custom_field_'.$value['id'].'_required', $options)) { + if(filter_var(($options['_custom_field_'.$value['id'].'_required'] === 'on'), FILTER_VALIDATE_BOOLEAN) ){ + $label = '*'.$label; $required = true; + + } } ?>