Adding custom profile fields to Member Profile
-
I’ve been trying to add custom fields to the member profiles and have not been successful.
I tried to add
bp_member_profile_data( ‘field=the field name’ ) to the
members-loop.php
It’s not working. Could someone tell me if I’m doing something wrong?
-
In the WordPress Admin under the Users you will see a link called prifile fields. This is where you create fields.
Yea…I got that. Did that. I’m trying to use the code above to make them show up on the members page and the single members page and it’s not working.
When I try to add the code in, it’s not showing up and I think it’s because I’m not inserting it exactly right. I see the location that it is supposed to be, but I’m not sure I’m keying in the correct characters. Can someone help me with the exact location and characters? Is this the right code?
<?php bp_member_profile_data( ‘field=cancer type’ ); ?>
Or do I just need to insert the code without <?php..?>
When outside the members loop you have to pass it a user id.
bp_get_profile_field_data( array( ‘field’ => ‘cancer type’, ‘user_id’ => bp_displayed_user_id() ) );
I’m still not getting something right. Here is how it is showing up…
What do you mean by “outside the members loop?” I’m adding this code to
members/members-loop.phpHere is how I added it. I’m sorry if this seems like a stupid question…I just really need to get this working and usually can figure this stuff out..
ahh you need php tags. when you cut and paste you may need to retype single quotes.
`<?php bp_member_profile_data( 'field=cancer type' ); ?>`
I’m confused. The earlier code is supposed to be used outside the member loop and this most recent code is supposed to be used in the member loop?
I’ve inserted the most recent code and replaced the single quotes. Nothing is showing up. I just can’t seem to figure out why? Here is my latest code in the member-loop.php
Hi @ebraxton30,
maybe try with this:
<code>$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;bp_profile_field_data( array(‘user_id’=>get_the_author_meta(‘ID’),’field’=>’cancer type’));</code>
That did not work, either. Can someone please offer a solution?
Here it is see http://pastebin.com/qLe9jXi6
Mods would you be so kind as to put the pastebin link in the first post and delete the others.
Apologies for the mess!
No. it blanked out the screen.
The example may have broke and needs a refresh, try this:
echo bp_member_profile_data( ‘field=Name’, bp_get_member_user_id() );
tried on /groups/single/members.php 1.6.3
none of the solutions are working !
That didn’t work either. I just am stumped.
Works for me. Make sure you are writing the field name exactly as it is. name does not equal Name.
Is working on members list page but not on group members list page.
To get a profile field value on the group member page (BP 1.6.3 tested), use this:<code><?php echo xprofile_get_field_data( ‘the_field_name‘ , bp_get_group_member_id() ); ?></code>
Take care, the the_field_name is case sensitive.
That worked like a charm! Now I have a question.. this is my code:
Belt Level: echo xprofile_get_field_data(‘Belt Level’ , bp_get_group_member_id() );
I have in this profile drop down field about 10 choices. Is it possible to somehow have this output assign a dynamic class or id pending on what your Belt Level is? I want to display this a color block with some css rather then just text on the screen.
Thanks!
I finally figured this out. I am using Gravity Forms user registration plugin to work with my Buddypress theme. My field names varied slightly between the custom profile field name and what I put on the user registration form. I realized that I must use field name as it is entered in the WordPress Custom Profile Field.
I do have one question…I would like to display the field name as well as what was entered in that field. For example, this site is a cancer site and users will enter their type of cancer. I would like it to read “Type of Cancer: Breast” rather than “Breast”
Any suggestions?
- The topic ‘Adding custom profile fields to Member Profile’ is closed to new replies.