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
Add custom profile field to member information on the sidebar
Avatar
Julian Paul Francis Kitagawa
Member
Free Members
sp_UserOfflineSmall Offline
Oct 1, 2015 - 11:20 pm

I used the "Custom Profile Field" plugin to add a "profession" field to my member's profile. I'd like to display this information in the member information that displays on the sidebar, under "location".

I don't see an option to do this... but would it be possible by modifying the theme? (I'm using Reboot with the child theme over it with custom css).

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 12:17 am

yes, you need to add the template function for displaying the custom profile field where you want it...

see:  https://simple-press.com/docum.....le-fields/

as always, we strongly recommend a child theme or a custom theme for your changes...

Avatar
Julian Paul Francis Kitagawa
Member
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 2:42 am

Thank you for this.

Perhaps I'm misunderstanding how to edit via a child theme... I added the code (from the example in the page linked, but instead of adding a line in the side-bar member information, it adds an avatar with the line *under* the whole forum.

FYI this is the code:

<?php
# --------------------------------------------------------------------------------------
#
# Simple:Press Template
# Theme : Reboot
# Template : Topic View
# Author : Simple:Press
# Version : 1.0
#
# The 'Topic' template is used to display the Topic/Post Index Listing.
#
# This template makes a call to either the desktop or mobile template
# depending on what device the forum is being viewed through.
#
# To edit the Topic view for desktop use- templates/desktop/spTopicViewDesktop.php
# To edit the Topic view for mobile use- templates/mobile/spTopicViewMobile.php
# --------------------------------------------------------------------------------------

global $spDevice;

if ( $spDevice == 'mobile' ) {
sp_load_template('mobile/spTopicViewMobile.php');
} else {
sp_load_template('desktop/spTopicViewDesktop.php');
}

sp_UserAvatar('tagClass=spPostUserAvatar spCenter&context=user', $spThisPostUser);
sp_PostIndexUserName('tagClass=spPostUserName spCenter');
# Added poster's game type selection to the forum post, poster information section.
if (function_exists('sp_CustomProfileFieldsDisplay')) sp_CustomProfileFieldsDisplay('Profession', $spThisPostUser->ID);
sp_PostIndexUserLocation('tagClass=spPostUserLocation spCenter');

?>

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 5:00 am

Hey Julian,

I'm a bit confused.. Is that your entire spTopicViewDesktop.php file from your child theme?

If it is, you can't just add a template to a child theme that only includes the changes you want to make, there is no way for SP to determine where to slot the changes in if you like, it has to be the entire template. 

However, if that's just an excerpt but your code is literally at the top of the template, it looks like the code is in the wrong place. For example using Reboot, you would be looking to add the code to the section

'# Column 1 of the post row'

which starts on line 131 in the full template. This section contains (in order) avatar, username, location, rank etc.. So just add your custom profile function after location and before rank.

Hope that helps.. Sorry if I'm missing something, if so please explain..

Avatar
Julian Paul Francis Kitagawa
Member
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 6:48 am

Thank you!

That makes perfect sense... I'm not too sure why I thought I could just paste it there, and it would work.

I've got it working now... but I still need to style it.

I've got the line:

if (function_exists('sp_CustomProfileFieldsDisplay')) sp_CustomProfileFieldsDisplay('Profession', $spThisPostUser->ID);

... how can I add a CSS class to this to make it look the same as the rest? (e.g. the same as "location")

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 8:48 am

That depends, I haven't got one set up so can't check quickly.. When you right click and inspect the custom profile field on your forum, what class does it use?

You might be better off using sp_CustomProfileFieldsDisplayExtended() which from the look of it (again without setting one up to test) offers the use of the 'tagClass' argument, meaning you could give it a unique class and style it to fit the current user info section text.

Have you got a link? Will happily take a look so we can say for sure what you need to add / edit.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 9:31 am

yes, sorry, should have been more explicit... long hard day yesterday...

if you are display in the profile (which you did mention), the proper tag to use would be sp_do_CustomProfileFieldsProfileDisplay() as @ike mentions since its meant for profiles...  the others are more generic for use anywhere...  this one is meant to match the profile display...

Avatar
Julian Paul Francis Kitagawa
Member
Free Members
sp_UserOfflineSmall Offline
Oct 2, 2015 - 6:16 pm

ike and @mr-papa - this is working perfectly now. Thank you so much!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 3, 2015 - 1:18 am

good to hear... thanks for the update...

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: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625