site-reviews/get/review is only triggered when querying a single review with the glsr_get_review helper function.
To modify a review before it is rendered on the page, you will need to use site-reviews/review/build/before. For example:
add_action('site-reviews/review/build/before', function ($review) {
$review->set('author', 'Jane Doe');
});
Another thing. If you assigned a user, why the author is not this user?
Can i do this?
If you want to assign the person who submitted the review to their own review, you will need to:
1. Only allow review submissions from registered users.
2. Hide the “name” and “email” fields in the form so that the current user details are used
3. use assigned_users="user_id" on the review form
For example”
[site_reviews_form hide=name,email assigned_users=user_id]
-
This reply was modified 5 years, 4 months ago by
Gemini Labs.
The ‘site-reviews/review/build/before’ is perfect!! Thank you!!
The initial assign is ok (in the form). I do not have problems. But when i reassign (editing) the user do not change in review.
Do I need to create a function to reassign one user and change the author info?
Reassigning the user will not change the author of the review, these are two different things:
1. The author is the person who submitted the review. If you have done #1 and #2 as shown above, then the logged in user will automatically be the author of the review (the user ID will be the author of the review post in the database, and the user’s display name and email will be saved to the review.
2. Assigning a user to a review associates their user ID to the review in the database. It does not however change the author ID of the review post.
If you need to change the name and email of a review, simply edit the review and change the details. This will not however change the author ID of the review post.
If you need to change the author ID of the review post, you will need to use the following code snippet (you can use the Code Snippets plugin for this):
add_action('admin_init', function () {
add_post_type_support('site-review', 'author');
});
And then use the Author meta box to change it when editing the review:

Thank you, but in this case i must elevate role of users.
I prefere do this,
add_action('site-reviews/review/build/before', function ($review) {
if (isset($review['assigned_users']) && count($review->assigned_users)> 0 ){
um_fetch_user($review->assigned_users[0] );
$review->set('avatar', um_get_avatar_uri( um_profile('profile_photo'), 40 ));
$user_info = get_userdata($review->assigned_users[0]);
$review->set('author', $user_info->display_name);
} else {
$review->set('author', 'Anonymous');
}
return $review;
});
Author was assigned correctly!!! But, avatar has not changed!
Avatar url from UM is ok (i tested). But $review->set(‘avatar’, URL) not change the url.
Shouldn’t it work the same way?
You probably have the “Regenerate Avatars” option enabled.
If that option is enabled, Site Reviews will generate the avatar URL (after that hook is run) based on:
1. The email saved to the user profile of the user ID who is the author of the review post.
2. Or, if an author (user ID) is not found for the review post, then the email saved to the review will be used.
So to solve, you will either need to disable the “Regenerate Avatars” option, or use the site-reviews/review/value/avatar hook like this:
add_filter('site-reviews/review/value/avatar', function ($value, $tag) {
if ($userId = glsr_get($tag->review->assigned_users, 0)) {
um_fetch_user($userId);
$avatarSize = glsr_get_option('reviews.avatars_size', 40);
return um_get_avatar_uri(um_profile('profile_photo'), $avatarSize);
}
return $value;
}, 10, 2);
The list of all available filter actions and hooks can be found here (they are not documented however, and undocumented hooks, i.e. documentation not provided on the Help page, are subject to change!):
https://github.com/pryley/site-reviews/blob/master/HOOKS.md
-
This reply was modified 5 years, 4 months ago by
Gemini Labs.
-
This reply was modified 5 years, 4 months ago by
Gemini Labs.
Paul, your work is incredible. Wonderful support. I will contribute to your project. Unfortunately there is a very big difference between the value of our coins and my financial collaboration will not be much for you, but it will be a way to pay some of the time you have dedicated.
Thanks for all
Thanks @lfbsilva
Please also consider leaving a review on WordPress. π