Do you have inserted text (information) into the fields and profiles at issue?
If you have old profiles and create later new fields, this fields are of course empty. So you have to update the profile information at first.
Thanks @1a-spielwiese and @danbp,
I created new fields and didn’t updated profile that was the reason of not showing.
Is there any way i can access the data in the fields. I created field named Skill i want to access the data in that field and use in other pages/post.
Yes, within the administration area of your WordPress-installation is a menue point “users”. There is every user listed, and you as administrator can update all profiles – and the users themselves can update their own profile.
Thanks @1a-spielwiese,
Is there any way to search users using xprofile fields.
E.g. In my xprofile field i have named “Skills” i want to search all user having the Skill = I.T.
I made Skills as checkbox.
I don’t know, whether this is possible in the administration area.
But may you can adapt this for your purposes:
https://buddypress.org/support/topic/add-profile-field-to-order-by-drop-down-menu/
I guess, to order the members due to a certain field implies to see, whether it is filled in or not.
The solution below is valuable for front-end publishing only.
If you want to see the “skill” profile field data on another page, like a custom page, you have to add a placeholder (do_action(the_skill) to this page template.
As you’re outside of the profile loop, you also have to fetch a user_id to get the data.
Add this function into the child-theme functions.php or into bp-custom.php
function bpfr_field( $custom_field ) {
global $bp;
// is xprofile component active ?
if ( bp_is_active( 'xprofile' ) )
// fetch the user_id
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
// fetch the data
$custom_field = xprofile_get_field_data('42', $current_user_id); // 42 is a field ID
// show the data
echo '<div class="authorinfo">'. $custom_field . '</div>';
}
add_action( 'myfield', 'bpfr_field', 1 );
And this piece of code goes into the template.
<?php do_action( 'myfield'); ?>
Of course you can also use an existing placeholder. In this case, you just have to modify the add_action ($placeholder, $function)
Thanks @danbp,
Its cool thanks for answer, Will make changes according to me but u made me damn happy. Thanks once again.
Thanks @1a-spielwiese too
Hi @danbp, Thanks for all help it will help me more. For myself i made changes to code given by you and i was able filter members(users) according to skills(xprofile field) from this:
function bpfr_field( $skill_field) { //$skill_field imported from do_action function
global $bp;
// is xprofile component active ?
if ( bp_is_active( 'xprofile' ) )
// fetch the user_id
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
$blogusers = get_users( ); //to get all user data from database
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
// fetch the data
$sk = xprofile_get_field_data('8', $user->ID); // 8 is a field ID
// show the data
foreach($sk as $skill){
if ($skill == $skill_field){
echo '<div class="authorinfo"><a href="http://YOUR_URL/members/' . $user->user_login . '/profile"
target="_blank">' . $user->display_name . '</a></div>'; //to add link for user profile
}
}
//echo '<span>' . esc_html( ) . ' </span>';
}
}
add_action( 'myfield', 'bpfr_field');
I made a dropdown to select and skill value and attached it to do_action like this
do_action( 'myfield', $skillname );
and it worked.
Thanks for your support, 1000 likes to your answer and help 🙂
You’re welcome ! Glad you got it to work. ,;-)