Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
How to display custom profile fields
Avatar
pmac1965
Member
Free Members
sp_UserOfflineSmall Offline
Jan 3, 2013 - 2:03 pm

I am trying to figure out how to have custom profile fields displayed and I am unsure of how to go about it. Ideally, I would like the field displayed underneath a users avatar as well as in their profile underneath their bio.

 

From what I can gather from the codex, in order to have it display under the avatar, I would insert this tag in to a template file:

sp_CustomProfileFieldsDisplay($name, $spPostUser->ID);
 
And I wold change "name" to the name I gave the profile field.
 
My questions are:
 
1) Specifically which template file do I insert the tag, and where in the file would I insert it to render under a users avatar?
2) Is the "ID" automatically populated? If not, how do I get the user ID's especially if there are thousands of members?
 
Thanks!
 
 
 

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 3, 2013 - 6:57 pm

which users avatar???  the avatar is displayed in many locations...

again on the user id, it depends... if you do not supply the user id, it will auto fill the id of the current logged in user...  so if you just want the current user, that is fine...  but if you are displaying it somewhere that is not current logged in user based, you need to supply it...  and how you supply it depends on where  you are using the custom profile field since we normally have a user id setup, but it will vary from location to location...

so for example, if you want it to show in the topic view page, for each post, under the users avatar in the post info section, it would be something like:

sp_CustomProfileFieldsDisplay($name, $spThisPostUser->ID);

if you were showing it under the avatar in the users profile, it would be

sp_CustomProfileFieldsDisplay($name, $spProfileUser->ID);

of course, for both, you need to replace the $name with the field name...

so did I guess one of the avatar locations?  if not, please specify which one...

 

 

Avatar
pmac1965
Member
Free Members
sp_UserOfflineSmall Offline
Jan 4, 2013 - 9:26 am

You guessed both. :)

Ok, so I have tried and this and I am not getting the field to display. For the topic view I went to

spTopicView.php

and inserted the following

sp_CustomProfileFieldsDisplay($name, $spThisPostUser->ID); and I changed "name" to the corresponding field

I inserted that tag right after the following line:

sp_PostIndexUserName('tagClass=spPostUserName spCenter');

 

After doing that, I see no changes. Obviously I am doing something wrong.

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 4, 2013 - 2:37 pm

can you please post exactly what you are entering here please... would like to check the syntax...

Avatar
pmac1965
Member
Free Members
sp_UserOfflineSmall Offline
Jan 5, 2013 - 10:45 am

It is exactly as posted above. I have included a screenshot so you can see exactly what I did.customDisplayField.jpgImage Enlarger

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 5, 2013 - 1:50 pm

So what does the variable $test equal? Does it resolve to the item name needed? And why not just put that in quotes? Why use a variable?

andy-signature.png
YELLOW
SWORDFISH
Avatar
pmac1965
Member
Free Members
sp_UserOfflineSmall Offline
Jan 5, 2013 - 2:18 pm

"test" is the name of the custom field when I created it.

 

>>>>>>Does it resolve to the item name needed? And why not just put that in quotes? Why use a variable?

I have no idea, I don't code at all. I am just following the instructions from the codex.

 

See the attached screenshot. I created a textarea that is viewable when you edit your profile and added the word "test" to the text area. I addedtest.jpgImage Enlarger the code exactly as you see in the above example in the hope that it would render under the avatar but no such luck.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 5, 2013 - 2:21 pm

Well then there is no such varoable as $test and the routine is just getting no value.
Instead of using a variable name ($test) you should be using 'test' in quotes. The name of the new custom field.

andy-signature.png
YELLOW
SWORDFISH
Avatar
pmac1965
Member
Free Members
sp_UserOfflineSmall Offline
Jan 5, 2013 - 2:41 pm

Thanks, i would never have never known that from the codex. The way it reads, it makes it sound as if its as simple as swapping out "name" for the new field name.

Glad I got that sorted. :)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 5, 2013 - 4:15 pm

thanks for the update...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
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: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625