[Resolved] Latest Update Gives Many Undefined Index Errors
Just updated the new version of this wonderful plugin which I use everywhere on my websites, including the public website and WP dashboard on the Options page.
Unfortunately the new update caused many undefined index errors to pop up now. I think I know a symptom of the cause. It is because I add a group of custom field options with different features to my page template, so the code for the field is there (with an if conditional to check for values) whether there is any information in the field or not. With the new conditional logic feature (amazing new addition) I allow the user to chose whether or not they want to use that feature with a check box on the WP Edit screen. For instance I have setup a special video player and photo album code that will appear or not based on the user entering the values for those fields. I am very excited for this new way of creating theme options on pages.
So what I have come to realize is this “undefined index error” message appears when there is no information entered in a field, while the code is still there checking if it exists. Before the update all I needed was an if conditional for field values so it would check whether to use the rest of the code. Now apparently it causes PHP to attempt to access something that is not there, therefore giving me the undefined index error. I looked into this a little bit and apparently it is something that happens in plugins when isset() is not used correctly.
The error only appears in the latest update of this plugin. Please fix so I can update my website without worrying a bunch of these errors will now appear.
Below is an example code that causes the error when the initial if conditional returns no value.
<?php // TESTIMONIALS CUSTOM FIELDS if(get_field('testimonials')) : ?> <ul id="testimonials"> <?php while(the_repeater_field('testimonials')) : ?> <li> <p><?php the_sub_field('feedback') ?><br /> <em><?php the_sub_field('customer') ?></em></p> </li> <?php endwhile; ?> </ul><!-- end .testimonials --> <?php endif; // end testimonials fields ?>
- The topic ‘[Resolved] Latest Update Gives Many Undefined Index Errors’ is closed to new replies.