The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Using avatar from j...
 
Share:
Notifications
Clear all

[Solved] Using avatar from jReviews

10 Posts
2 Users
1 Reactions
1,304 Views
Posts: 9
 Baze
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@baze)
Active Member
Joined: 4 years ago
[#3840]

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?


9 Replies
Asti
Posts: 8210
 Asti
Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@asti)
Illustrious Member
Joined: 8 years ago

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. 


8 Replies
 Baze
(@baze)
Joined: 4 years ago

Active Member
Posts: 9
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti i'm aware of that, the problem is that i don't know how to get userid from wpdiscuz, that's the question 🙂


Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@baze,

You can try this value get_current_user_id(). More info here: https://developer.wordpress.org/reference/functions/get_current_user_id/


 Baze
(@baze)
Joined: 4 years ago

Active Member
Posts: 9
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti but that will return the currently logged in user, i need the user id of the author of the comment.


Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@baze,

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.


 Baze
(@baze)
Joined: 4 years ago

Active Member
Posts: 9
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti Works like a charm, thanks!!!


Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Asti
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@baze,

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.


 Baze
(@baze)
Joined: 4 years ago

Active Member
Posts: 9
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti just did (user: gixxermkd), thanks again guys!


Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Asti
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

Thank you very much @baze,

We really appreciate it. 


Share: