• Resolved knubew

    (@knubew)


    Hi,

    I’ve migrated to V 5.12.2. Nearly everythings works fine and the data in all 4 gslr tables look good so far.

    I use the setting that all users (including users who are not logged in) can create reviews of individual posts.

    Although I have already read various posts here in the forum, I cannot find out how to filter reviews either by “user_id” (or alternatively by category) when a user has logged in. Logged in users should only be able to see the reviews that have been written for their posts.

    I also don’t understand why you can transfer a user ID via “assigned_users” when creating a new review, but this is not automatically transferred to the “posts” table as the id for the “post_author” field. I think that would make perfect sense, wouldn’t it ?!`

Viewing 4 replies - 16 through 19 (of 19 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Site Reviews uses the get_terms function to get the list of categories. It is used like this:

    $terms = get_terms([
        'count' => false,
        'fields' => 'id=>name',
        'hide_empty' => true,
        'taxonomy' => 'site-review-category',
    ]);

    Unfortunately, it seems that if you include the hide_empty parameter (to only return terms that have been assigned), the function only returns the terms that have been assign to an entity with a “publish” (i.e. approved) post status.

    I will have to look into this further to see what can be done. I may have to use a raw SQL query instead.

    Thread Starter knubew

    (@knubew)

    Okay, I understand.

    I will have to look into this further to see what can be done. I may have to use a raw SQL query instead.

    Oh man, thank you very much. I’m glad, that we’ve found the reason.

    I really need the filtering for my clients, because each client should only be able to see the reviews for his own posts (articles). Under no circumstances may the client see reviews from other clients.

    Plugin Author Gemini Labs

    (@geminilabs)

    In that case, instead of (or as well as) using categories, you may wish to use the assigned_users option on the shortcodes and have reviews assigned to the users who need to be able to respond to them.

    If you do use the assigned_users option and want to hide any reviews on the “All Reviews” page that have not been assigned to the logged in user, then this snippet may help: https://pastebin.com/5jHK5LQR

    You will likely also want to give those users the respond_to_site-reviews and respond_to_others_site-reviews capabilities so that they can respond to the reviews.

    For example, using that snippet will allow administrators to see all reviews:

    And authors to only see reviews which have been assigned to them:

    In that second screenshot you can see that the author only sees the reviews that have been assigned to them. They cannot edit the review (because they are not the post_author of the review), but they have the “respond_to_*” capabilities so they can still respond to reviews from the “All Reviews” page.

    • This reply was modified 3 years, 8 months ago by Gemini Labs.
    Thread Starter knubew

    (@knubew)

    Sorry, I was out of the office over the weekend.

    Thank you for the code snippet. It looks great. I’m going to try it for sure because it seems it could do exactly what I need. Among other plugins things, I also work with the “Pods – Custom Content Types and Fields” plugin. I can easily pull the ID for assigned_user from this data.

    Maybe then I can even do without the categories, because I originally used the categories for this purpose in an older Site Reviews version. Since the Site Reviews data are now stored in separate tables, my code snippets no longer worked as they should originally anyway.

    When I have tested everything extensively, I will be happy to report again here.

    Thank you for your incredibly good and dedicated support.

    • This reply was modified 3 years, 8 months ago by knubew.
Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Filtering in Version 5.12.2’ is closed to new replies.