bp_member_profile_data( ‘field=the field name’ ); –> try bp_member_profile_data( ‘field=Class’ );
@arkokoley, @wdfee
works better by using both xprofile_get_field_data and a user_id !
$user_id = bp_get_member_user_id();
// if “Class” is the field name
$mystuf = xprofile_get_field_data( ‘Class’, $user_id );
Application example here:
http://wpmu.org/buddypress-profile-data-on-multisite/
@chouf1, @wdfee
Thanks for the help but neither code is useful for me.
bp_member_profile_data( ‘field=Class’ ); returns an error stating unexpected “=”
@chouf1, your code doesn’t return anything atleast in my case. Any ideas what I did wrong? This is what I coded:
<?php
global $current_user;
$user_id = bp_get_member_user_id();
$class = xprofile_get_field_data( ‘Class’, $user_id );
echo $class;
?>
@arkokoley,
you coded it wrong, and we don’t know where you coded it. The mentionned elements i give you should be into a function, and depending where it must appear, you have to add or alter an existing filter.
I can’t help you more because you don’t give any details for what you exactly want to do so , on witch theme (name?) and BP version you use.
‘Displaying values on the theme’s navbar‘ is not enough, sorry !
<?php if ( $data = bp_get_profile_field_data( ‘field=class’ ) ) : ?>
” > <?php bp_profile_field_data(‘field=class’);?> <?php bp_profile_field_data(‘field=Name’);?>
<?php endif;?>
I’m not sure that it’s work’s for you (where do you want to take this). This code just check if your profile field has value and appear this value and the name-value. (clikable). I hope it helps you.
This is the site.
@chouf1, I use WordPress-Bootstrap by 320press. In the circled tab, i want to display the class of the student. Also depending on the Class menus with different elements will be put in that sidebar.
How do I do this? Even if I could compare the value of the profile field it would do.
For example,
if( bp_profile_field_data(‘field=class’);==X)
<do something here.>
something like this.
I coded it directly into the theme’s header, where the rest of the sidebar is. Should I do something else? I’m a newbie to PHP, though I know C++ to some extent.
here’s a untested function. Would perhaps output the member name and the Class he belongs
function bpfr_member_class($myinfo) {
global $bp;
$user_id = bp_get_member_user_id();
$membername = xprofile_get_field_data( ‘Name’, $user_id );
$data = xprofile_get_field_data( ‘Class’, $user_id );
if( $data )
$myinfo = ‘<div class=”myinfo”>’. $membername.’ CLASS: ‘. $data .'</div>’;
return $myinfo;
}
I’m a newbie to php (me also) – this is not an excuse especially when you’re going to code on the fly without reading documentation and forum topics.
What you doing wrong 😉
– You’re coding directly into your theme
– You don’t read the answers you receive and you don’t answer the questions.