• Resolved jonathangallo

    (@jonathangallo)


    I used the following code to add a custom field, which I changed to checkbox. This checkbox is optional and I’ve changed the review.php to add this custom field in the review widget. But when I leave the checkbox unchecked, it just displays {{ my_custom_field }}. I tried to modify the foreach loop in the last function from the code snippet but I can’t manage to find a solution to get these reviews with the checkbox unchecked. Is there something I can do in review.php or should this be done in PHP? I have a “solution” in CSS but it isn’t enough, I would prefer to not write out the value when I leave the checkbox unchecked. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Try adding something like this at the end of the “site-reviews/review/build/after” hook (before the return statement):

    if (!isset($renderedFields['my_custom_field'])) {
        $renderedFields['my_custom_field'] = '';
    }
    • This reply was modified 6 years, 8 months ago by Gemini Labs.
    Thread Starter jonathangallo

    (@jonathangallo)

    Worked perfectly! As always, thank you for the quick response!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hide custom fields in review widget when empty’ is closed to new replies.