• Resolved tuomvii

    (@tuomvii)


    Hi!

    I added this code to the functions.php file:

    /* ADD CUSTOM FIELD TO SITE REVIEWS */
    add_filter('site-reviews/config/forms/submission-form', function ($config) {
        $config['favourite_line'] = [
            'label' => __('Yksi lempilauseistasi kirjassa (vaihtoehtoinen)', 'divi'),
            'placeholder' => __('', 'divi'),
            'required' => false,
            'type' => 'textarea',
        ];
     return $config;
    });

    It sure adds a new custom field to the form, but how do i get it to show on reviews and on the admin side in the single review?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tuomvii

    (@tuomvii)

    I managed to get the inputs of the custom fields to show with this one after creating the new Site Reviews folder with the review.php file inside to my theme folder:

    add_filter('site-reviews/review/build/after', function ($renderedFields, $review) {
        foreach ($review->custom as $key => $value) {
            if ($key == 'service_rating') {
                $value = glsr_star_rating($value); // render the stars from the rating value
            }
            if (is_array($value)) {
                $list = array_reduce($value, function ($result, $item) {
                    return $result.'<li>'.$item.'</li>';
                });
                $value = '<ul>'.$list.'</ul>';
            }
            $renderedFields[$key] = '<div class="glsr-custom-'.$key.'">'.$value.'</div>';
        }
        return $renderedFields;
    }, 10, 2);

    Still, am I able to get the custom field inputs to appear in the reviews on the admin dashboard?

    Plugin Author Gemini Labs

    (@geminilabs)

    @tuomvii Please refer to this: https://pastebin.com/4fvKErcp

    Particularly on lines 76-92.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to show custom fields in the reviews?’ is closed to new replies.