Support » Plugin: Site Reviews » multiple star reviews

  • Resolved gediweb

    (@gediweb)


    For some reason, my support question got deleted yesterday.

    I’d like to do multiple review star ratings.I followed the directions from the link you posted on other support question. The problem is there is only one star rating in the example you provide. I’d like 4 Star Ratings. Office Staff, Wait Time, Doctor Bedside Manner & Overall Rating.

    – So far, The form is perfect. I have the 4 questions and stars to rate.

    – But the display is wrong. (Please see screenshot below) 3 out of 4 reviews are showing the number instead of stars on the review detail and there is code {{ }} at the top. I have a feeling I maybe did the array wrong (with multiple star ratings). Can you provide the correct way to display all star ratings?

    Thank you

    https://snipboard.io/czjGok.jpg

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

    (@geminilabs)

    As explained here, adding custom form fields is not actively supported. Thanks for your understanding.

    However, in this case I’ll give you some pointers on how to deal with multiple ratings:

    /**
     * Displays custom fields in the Review's "Details" metabox
     * Paste this in your active theme's functions.php file.
     * @return array
     */
    add_filter('site-reviews/metabox/details', function ($metabox, $review) {
        $ratingKeys = ['rating1', 'rating2', 'rating3']; // change these as needed
        foreach ($review->custom as $key => $value) {
            if (in_array($key, $ratingKeys) ) {
                $value = glsr_star_rating($value); // render the stars from the rating value
            }
            // ...
        }
        return $metabox;
    }, 10, 2);

    And:

    /**
     * Renders the custom review fields
     * Paste this in your active theme's functions.php file.
     * In order to display the rendered custom fields, you will need to use a custom "review.php" template
     * as shown in the plugin FAQ ("How do I change the order of the review fields?")
     * and you will need to add your custom keys to it, for example: {{ name_of_your_custom_key }}
     * @return array
     */
    add_filter('site-reviews/review/build/after', function ($renderedFields, $review) {
        $ratingKeys = ['rating1', 'rating2', 'rating3']; // change these as needed
        foreach ($review->custom as $key => $value) {
            if (in_array($key, $ratingKeys) ) {
                $value = glsr_star_rating($value); // render the stars from the rating value
            }
            // ...
        }
        return $renderedFields;
    }, 10, 2);
    • This reply was modified 1 year, 9 months ago by Steve Stern (sterndata).
    • This reply was modified 1 year, 9 months ago by Marius L. J.. Reason: Fixed missing parenthesis on posters behalf
    Thread Starter gediweb

    (@gediweb)

    That is definitely not what I had LOL

    it’s throwing me an error. Puts the site down:

    “There has been a critical error on your website.

    Learn more about debugging in WordPress”

    and here is what I get in the error log:
    [26-Feb-2020 16:39:37 UTC] PHP Parse error: syntax error, unexpected ';' in /home/almostdone/pmd.almostdone.website/wp-content/themes/cesis_child_theme/functions.php on line 231

    This is line 231:

                $value = glsr_star_rating($value); // render the stars from the rating value
    
    • This reply was modified 1 year, 9 months ago by gediweb.
    • This reply was modified 1 year, 9 months ago by gediweb.
    Plugin Author Gemini Labs

    (@geminilabs)

    Ah, sorry.

    This:

    if (in_array($key, $ratingKeys) {
    

    Should be this:

    if (in_array($key, $ratingKeys)) {
    
    Thread Starter gediweb

    (@gediweb)

    Thanks 🙂 That took the error away but I still get the code on top and now no reviews in details see screenshot”

    And I’m so sorry to be a pain. I just want to get this right.

    https://snipboard.io/TCV9Yk.jpg

    Plugin Author Gemini Labs

    (@geminilabs)

    Please see the updated link: https://pastebin.com/4fvKErcp

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘multiple star reviews’ is closed to new replies.