Support Forum
Helllo,
I need to filter user's names to show a title before name.
I already have this info as a wp usermeta.
I've opened the spTopicView.php template, where I can find, for example, the author post column: sp_PostIndexUserName('tagClass=spPostUserName spCenter');
but I'm not able to create a filter to alter that function.
----
Same problem trying to show custom profile fields. I've found this topic https://simple-press.com/suppo.....-fields-4/ where Mr Papa tells how to show a custom profile field with sp_CustomProfileFieldsDisplay($name, $userid);
but how do I get the $userid in forum loops?
I'm answering myself to the second question:
How to get user id inside Simple Press Post Loop?
This way: $spThisPostUser->ID
please correct me if I'm wrong.
But I still need to filter forum display name adding a title (Prof, Doc, Mr., etc...) before the name.
Is there a way to do this on forum display name or do I need to add this manually on template files?
I know it's a lot of places we are talking about.
is for that I'm looking for a filter, because I need that title to be always before display name (if that field is set, obviously)
I asked about the $spThisPostUser just because it was a related issue that I was supposing quick to answer
Ok Try this. bear in miund I have not really tested this myself!
add_filter('sph_user_class_meta', 'function1'); function function1($objList) { $objList['XXX'] = 'title'; } add_action('sph_user_class', 'function2'); function function2($userObj) { $userObj->display_name = $userObj->XXX . $userObj->display_name; }
Change 'function1' and 'function2' for your own function names in both the add filter/action calls and in the small functions themselves.
Change the 2 instances of XXX for the NAME of the meta item in the usermeta table.
And this code is probably best placed in the spFunctions.php file of the SP theme.
If this works it isn't going to change every instance but it should change quite a lot of them.
YELLOW
SWORDFISH
|
I'm having some troubles.
I've followed yourvery clear instructions, but maybe I'm done something wrong.
this is what I've pasted in the spFunctions.php of my SP theme
add_filter('sph_user_class_meta', 'sph_addMetatoObj'); function sph_addMetatoObj($objList) { $objList['cortesia'] = 'title'; } add_action('sph_user_class', 'sph_insertMetaInDisplayBame'); function sph_insertMetaInDisplayBame($userObj) { $userObj->display_name = $userObj->cortesia . $userObj->display_name; }
I'm having 3 different error messages, first two repeats a lot of times and the page looks like hanging in an infinite loop, at the end loads the third message and the whole site (without the meta before the names)
Theese are the 3 errors:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /web/problem-with-post-edit-buttontdocs/www.[...]/wp-content/plugins/simple-press/sp-api/sp-api-class-user.php on line 131
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /web/problem-with-post-edit-buttontdocs/www.[...]/wp-content/plugins/simple-press/sp-api/sp-api-class-user.php on line 142
Warning: Invalid argument supplied for foreach() in /web/problem-with-post-edit-buttontdocs/www.sviluppointergraf.it/problem-with-post-edit-buttonome/[...]/wp-content/plugins/simple-press/sp-api/sp-api-class-user.php on line 294
(I've added the [...] to hide real URL)
THis happens in forum home, forum view and topic view
1 Guest(s)