• Resolved stylise

    (@stylise)


    Hello. I want users to have the option of leaving a rating without being forced to write a review.

    Is there a way to make the [site_reviews] shortcode only display reviews that have content, while hiding the “reviews” that are empty?

    Thanks in advance.

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

    (@geminilabs)

    You can use the site-reviews/create/review-values hook to assign a category to new reviews if the review title and content is not empty. Then, you can use this category in the [site_reviews] shortcode to only display reviews assigned to that category.

    For example, this code snippet will automatically assign new reviews which have the title and content to a “full-review” category:

    https://pastebin.com/jdZhu4QN

    Now you can use the shortcode with the assigned_terms option to only display reviews which have been assigned to the “full-review” category, like this:

    [site_reviews assigned_terms="full-review"]

    This ensures that pagination works, and no hacks required!

    • This reply was modified 2 weeks, 4 days ago by Gemini Labs.
    Thread Starter stylise

    (@stylise)

    Thank you for the suggestion and custom code. We aren’t using titles for what it’s worth. Just rating, review, name, and email.

    Unfortunately it doesn’t appear to be working as expected, both with form submitted reviews and manually created reviews. Review with no content still shows up under [site_reviews].

    Plugin Author Gemini Labs

    (@geminilabs)

    If you aren’t using titles, you will need to remove the check in the beginning of the code snippet that checks the title.

    Remove this part:

        // skip category assignment if the review title is empty
    if (empty($values['title'])) {
    return $values;
    }

    Also, the code snippet will only work for newly submitted reviews. For previously submitted reviews, you will need to manually assign them to a “full-review” category.

    • This reply was modified 2 weeks, 4 days ago by Gemini Labs.
    Thread Starter stylise

    (@stylise)

    @geminilabs That part of the code was removed before posting.

    Edit: Okay sorry, I didn’t make the category first. Testing now.

    • This reply was modified 2 weeks, 4 days ago by stylise.
    Thread Starter stylise

    (@stylise)

    @geminilabs Thank you, it appears to be working now!

    I greatly appreciate your assistance.

    Plugin Author Gemini Labs

    (@geminilabs)

    @stylise You’re welcome! If you are enjoying working with Site Reviews and have some time, please consider leaving a review. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.