Support Forum

Add custom profile field to member information on the sidebar

JK Julian Paul Francis Kitagawa
Julian Paul Francis Kitagawa
Member

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).

8 Answers

New Answer

MP Mr Papa
Mr Papa
Member

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

see:  https://simple-press.com/documentation/codex/plugins/our-plugins/available-plugins/custom-profile-fields/

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

JK Julian Paul Francis Kitagawa
Julian Paul Francis Kitagawa
Member

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’);

?>

IK Ike
Ike
Member

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..

JK Julian Paul Francis Kitagawa
Julian Paul Francis Kitagawa
Member

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”)

IK Ike
Ike
Member

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.

MP Mr Papa
Mr Papa
Member

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…

JK Julian Paul Francis Kitagawa
Julian Paul Francis Kitagawa
Member

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