Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Get avatar in spTopicView.php
Avatar
sptab
Member
sp_UserOfflineSmall Offline
Feb 24, 2012 - 12:21 pm

I'd like to make some changes on the way the avatar and rank icons are displayed in my theme.

Basically I am trying to modify spTopicView.php not to display the avatar icon if the avatar not been configured and it is left as default (guest/member).

I am testing the following in the post loop $spThisPostUser->avatar['uploaded']

It works fine except if the user has changed his avatar in Wordpress rather than in SP in which case $spThisPostUser->avatar['uploaded'] is still empty. Is there anyway to get the avatar in situation ?

 

Thank you.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Feb 24, 2012 - 12:28 pm

I would suggest just grabbing the user avatar with the current template tag, sp_UserAvatar(), but instead of having it echo out, set the get=1 argument and you will  just be given the avatar data... and you can compare it to the default avatar filename and use or not use...

Avatar
sptab
Member
sp_UserOfflineSmall Offline
Feb 24, 2012 - 1:07 pm

Thanks for the tip.

Here is my function call, as it may help others.

$arAvatar=sp_UserAvatar('get=1&context=user', $spThisPostUser);

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Feb 24, 2012 - 1:37 pm

yes, that should get you the info... good work!

Avatar
JohnnyNT
Member
Free Members
sp_UserOfflineSmall Offline
Mar 3, 2012 - 1:03 pm

In the same file (spTopicView.php) i am trying to do next thing: 

if(usergroup = 4){echo someimage}

 

This should go under avatar. Is it possible to do something like this (if it is, some hint please 🙂 )? 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 3, 2012 - 7:27 pm

for each post, the $spThisPostUser object will contain:

 [memberships] => Array
        (
            [0] => Array
                (
                    [usergroup_id] => 2
                    [usergroup_name] => Members
                    [usergroup_desc] => Default Usergroup for registered users of the forum.
                    [usergroup_join] => 0
                )

        )

which is a list of memberships...   so you can check the usergroup_id..  and then echo what you want...

or you can simply use the:

sp_PostIndexUserMemberships();

template tag which will show the usergroup memberships directly for you...  see the function itself in the code for available arguments...

Avatar
JohnnyNT
Member
Free Members
sp_UserOfflineSmall Offline
Mar 7, 2012 - 2:50 pm

Cool, thank you (again 😀 ) , i managed to make this:

 

 if ($spThisPostUser->memberships[0]['usergroup_id'] == "4") {$mesage = 'This guy is cool';} else { $mesage  =  'Not cool  ' ;}

echo  $mesage; 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Mar 7, 2012 - 2:53 pm

Good one 🙂

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17357
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10123
Posts: 79616