Support Forum

Show Forum Avatar

PU puttee
puttee
Member

Since simple press v5.0 the function sf_show_forum_avatar();  doesnt work anymore. 

I used this function in my theme function.php to diplay the avatar next to the comment text in the wordpress front end.

e.g.: sf_show_forum_avatar($comment->comment_author_email); 

Is there a new function to fix?

9 Answers

New Answer

MP Mr Papa
Mr Papa
Member

sp_UserAvatar(); is what you want…

see wp-content/simple-press/forum/content/sp-common-view-functions.php for all the details and arguments you can pass to the function.

but basically, you want:

sp_UserAvatar($args, $comment);

at a minimum, you will want to pass context=user in the args… ie

sp_UserAvatar(‘context=user’, $comment);

of course, you can add more args if you want to change more from defaults…

PU puttee
puttee
Member

Mh, I use the following code atm: 

<?php sp_UserAvatar('context=user&size=40&imgClass=spAvatar', $comment); ?>

But, not the user/member specific avatar is shown in the comments-list:

www.miranda-fusion.de/simplepress2.jpg

Any ideas?

YS Yellow Swordfish
Yellow Swordfish
Member

on the profiles > avatars admin panel, do you have the option set to ‘replace WP avatar…’?

MP Mr Papa
Mr Papa
Member

a bit confused… are you talking about two separate things?

showing an avatar someplace and then having avatars in comments replaced?  cause that is two different things…

if all you want to do is show sp avatars in place of wp avatars, then just do like andy said in post 4… you dont need a template tag…  you ‘might’ be creating circular reference of sorts…  but not sure exactly what you are doing…

PU puttee
puttee
Member

Well, I tried to explain into more detail:

I would like to have an avatar in front of each comment in the comments-list of wordpress (not the forum). An individually avatar should be shown, if a comment was written by a still exisiting user (means: registered in my blog and the simple press forum). If a guest (not registered) write a comment to a thread of my blog, a default avatar should be shown next to his name in the comments-list.

Therefore I used this funtion: 

sp_UserAvatar('context=user&size=40&imgClass=spAvatar', $comment);

Edit: Now I found my mistake. I extended the function like the following:  

sp_UserAvatar('context=user&size=40&imgClass=spAvatar', $comment->comment_author_email);

The result looks like this, like it should:

www.miranda-fusion.de/simple-press3.jpg

 

This function works now for comments in articles, BUT not in the comments-list of pages. It gives me an error:

Fatal error: Call to undefined function sp_UserAvatar() in the function.php.

But works for articles. Maybe you have an explanation for that. Why is this function not working on static pages?

YS Yellow Swordfish
Yellow Swordfish
Member

This is because we do not load forum code where it is not necessary – which is good practice. Not sure if this will work but initially try calling this function before the avatar call:

sp_forum_ahah_support();

see if that helps.

PU puttee
puttee
Member

Great, superb… it works like a charm now.

Thanks for all your help.