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
How to filter Forum Display Name?
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 25, 2012 - 8:30 am

Two problems with that. Firstly that function will filter ALL display name plus, potentially other odd bits of data if appropriate and secondly you have no access to the users ID via that route.

andy-signature.png
YELLOW
SWORDFISH
Avatar
bluantinoo
ITA
Member
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 8:36 am

I'm not aware of potential oddities, but actually I need to filter display names everywhere.

About the user ID absence... maybe it can be retrieved with a custom query on wpdv object?

speaking about performances, what do you think it's better approach?

 

ps: how do I paste code correctly here?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 25, 2012 - 8:43 am

if you tried that your performance hit would be noticeable. The approach we are taking is already a little expensive with all those usermeta database reads - but that would be made a lot worse.

So where else is left then?

Paste your code into the post. Select it with your mouse cursor taking care to ONLY select the code. When selected, click on the the Syntax Highlighter toolbar button (far right) and select the language.

andy-signature.png
YELLOW
SWORDFISH
Avatar
bluantinoo
ITA
Member
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 9:03 am

this is where it's left:

1) Recent Post list

2) Watches List

3) subscribed list

4) forum stats

I think that's all

Avatar
bluantinoo
ITA
Member
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 9:41 am

Ok I'm lucky (and well-educated by your advices)

So in one move I've manages points 1, 2 and 3

with this:

add_filter('sph_topic_list_record', 'sph_addMetatoListLastPostObj');
function sph_addMetatoListLastPostObj($objData) {
    $cortesiaTitle = get_user_meta($objData->user_id, 'cortesia', True); 
    $objData->display_name = $cortesiaTitle . ' '.$objData->display_name;
    return $objData;
}

And I found out even the Members List:

add_filter('sph_members_list_records', 'sph_addMetatoMembersListObj');
function sph_addMetatoMembersListObj($objData) {
    $cortesiaTitle = get_user_meta($objData->user_id, 'cortesia', True); 
    $objData->display_name = $cortesiaTitle . ' '.$objData->display_name;
    return $objData;
}

 

I've just the Forum stats left now... I really can't find it!

Avatar
bluantinoo
ITA
Member
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 10:28 am

Well, after a deeper look I do not think there's a way to change display names in stats as we did i previous snippets.
I cannot find any class or object with stats records.

the only way I'm able to do it is just

1) copy/paste entire fuctions (sp_OnlineStats, sp_TopPostersStats, sp_NewMembers, sp_AdminsList) in my sp theme functions.php

2) rename them (sp_OnlineStats2, sp_TopPostersStats2, sp_NewMembers2, sp_AdminsList2)

3) adding my meta in a procedural way when theese functions build the Display name

4) Use theese cloned functions in my theme spFoot.php

am I correct?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 25, 2012 - 10:35 am

You will have to give me a little time as I need to disappear for a few hours but I will look closely later. we can work something out - don't worry.
By the way - whereabouts in Italy are you if you don't mind me asking?

andy-signature.png
YELLOW
SWORDFISH
Avatar
bluantinoo
ITA
Member
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 10:50 am

no problem Swordfish, take your time.

for the moment I'll clone the functions, if you will come up with a new wonder I'll take it happily

I'm from Rome (actually I can see San Peter's dome from my window) are you thinking to visit me? 🙂

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 25, 2012 - 4:01 pm

Sorry but it is going to have to be in the morning now. I have a plan to help you with an easy way to fix up the rest but need to run a few tests first. I will check this out in the morning.

Well a visit to Rome would be fun actually. We have been coming to Italy a couple of times each year recently but I have still not got to Rome. We are both (my wife and I) big fans of your country. I had a few days in Venice just a couple of weeks back in fact.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 25, 2012 - 7:27 pm

Ah, Roma!  love it there!  Have been maybe 10 or 12 times...  All but one on business, but always spend extra time there... Last trip a couple years ago and got to take the whole family!  great city!

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: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 617
Members: 17359
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10125
Posts: 79620