Hi guys,
i'm struggling to show the jReviews user avatar in the comments, basically i started this topic Cannot add php code in theme files – How-to and Troubleshooting – wpDiscuz Support Forum, since the plan was to add the php directly but as you explained i have to use custom shortcode with the php there.
So i've done that, but i cannot get the id of the user who is the poster of the comment, so i'm seeing specific avatars (from user id = 1) on all comments.
In the override for the avatar view i have:
<div class="{AVATAR_WRAPPER_CLASSES}">
[useravatar]
<div class="userinfo">
</div>
<div class="auth">{AUTHOR}</div>
</div>
And in functions.php i have:
function useravatar_link() {
ob_start();
require_once ABSPATH.'/wp-content/plugins/jreviews/jreviews/framework.php';
S2App::import('Component','userprofiles_profile','jreviews');
S2App::import('Model','everywhere_com_content','jreviews');
$profile = UserprofilesProfileComponent::getOneProfile($userId = "1");
echo '<img class="avatar avatar-64 photo" src="'.$profile['MainMedia']['media_info']['thumbnail']['65x65c']['url'].'">';
return ob_get_clean();
}
add_shortcode('useravatar', 'useravatar_link');
add_filter("wpdiscuz_comment_end", function ($commentOutput, $comment, $depth, $args) {
if ($depth > 2) {
$commentOutput .= "[useravatar]";
}
return $commentOutput;
}, 10, 4);
As you can see here in the line "$profile = UserprofilesProfileComponent::getOneProfile($userId = "1");" i need to put the user id of the comment poster instead of "1". So could you please let me know how can i get that?
Dear @baze,
Please note that we don't support any kinds of customizations. Just a bit hint.
$profile = UserprofilesProfileComponent::getOneProfile($userId = "1");
You'll need to paste the right value for the $userId. Don't add just 1.
In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.
@asti i'm aware of that, the problem is that i don't know how to get userid from wpdiscuz, that's the question 🙂
You can try this value get_current_user_id(). More info here: https://developer.wordpress.org/reference/functions/get_current_user_id/
In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.
@asti but that will return the currently logged in user, i need the user id of the author of the comment.
Please try to add this one in the functions.php file:
add_filter("wpdiscuz_comment_end", function ($commentOutput, $comment, $depth, $args) {
if ($comment->user_id) {
require ABSPATH . '/wp-content/plugins/jreviews/jreviews/framework.php';
S2App::import('Component', 'userprofiles_profile', 'jreviews');
S2App::import('Model', 'everywhere_com_content', 'jreviews');
$profile = UserprofilesProfileComponent::getOneProfile($comment->user_id);
$avatar = '<img class="avatar avatar-64 photo" src="' . $profile['MainMedia']['media_info']['thumbnail']['65x65c']['url'] . '">';
} else {
$avatar = '<img class="avatar avatar-64 photo" src="default-avatar.jpg">';
}
$commentOutput = str_replace('[useravatar]', $avatar, $commentOutput);
return $commentOutput;
}, 10, 4);
It may work fine.
In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.
@asti Works like a charm, thanks!!!
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.
In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.
@asti just did (user: gixxermkd), thanks again guys!
Thank you very much @baze,
We really appreciate it.
In case you want to say thank you! 🙂
We'd really appreciate if you leave a good review on the plugin page.
This is the best way to say thank you to this project and the support team.

