• Resolved julien1231

    (@julien1231)


    Hi everybody, I would like to know if it is possible to add a select field in the form which would serve as a title with the last version (6.4.1) of that amazing plugin. And how to do it of course.

    Thanks for your answer.

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

    (@geminilabs)

    You can do something like this:

    add_filter('site-reviews/config/forms/review-form', function ($config) {
        if (empty($config['title'])) {
            return $config;
        }
        $config['title']['type'] = 'select';
        $config['title']['options'] = [
            'Title 1',
            'Title 2', 
        ];
        return $config;
    });

    To add additional custom fields to the form, use the Review Forms addon.

    Thread Starter julien1231

    (@julien1231)

    Thank you for your answer but is it possible without Review Forms addon to add a selected field in the form?

    Plugin Author Gemini Labs

    (@geminilabs)

    The code snippet I provided changes the title field into a dropdown. Did you try it?

    Thread Starter julien1231

    (@julien1231)

    Yes I tried it by adding it to the site-reviews/config/forms/reviews-form.php file but as I am a beginner I may not have put in the right place. And then my website was a white screen…Could you please tell me where to add the code you provided?

    Thread Starter julien1231

    (@julien1231)

    Sorry, it’s perfect. I added to functions.php in my child theme and it works perfectly.

    Have a nice day

    Thread Starter julien1231

    (@julien1231)

    So I tried to leave a review as a visitor but when I publish it the title becomes a number. Is it possible to fix it please?

    Plugin Author Gemini Labs

    (@geminilabs)

    Ah, try this then:

    add_filter('site-reviews/config/forms/review-form', function ($config) {
        if (empty($config['title'])) {
            return $config;
        }
        $config['title']['type'] = 'select';
        $config['title']['options'] = [
            'Title 1' => 'Title 1',
            'Title 2' => 'Title 2', 
        ];
        return $config;
    });

    If you are not using a child theme or don’t want to modify your theme’s functions.php file, you can also use the Code Snippets plugin.

    • This reply was modified 1 year, 10 months ago by Gemini Labs.
    Thread Starter julien1231

    (@julien1231)

    Your code works perfectly.

    Thanks again for your patience and Happy New Year!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding custom field in form V6.4.1’ is closed to new replies.