Reply To: [Resolved] How to add fields from xprofile fields groups created by me
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 🙂