-
Author
-
September 6, 2014 at 04:23 #27759oneder22Participant
I’m trying to display the member’s username instead of full name in the member directory (members-loop.php). I’ve already tried the Buddypress Usernames Only plugin (http://wordpress.org/plugins/buddypress-usernames-only) and it has no effect on my site. I’ve also seen the instructions at https://archived.seventhqueen.com/forums/topic/avoid-using-real-names-on-sweet-date-theme but this is only for the profile page, which I’m fine with showing the full name. I only the need the full name hidden and username shown on the member directory.
Any help will be appreciated.
September 15, 2014 at 19:36 #28706CatalinModeratorHello,
You can first take a look at this:
http://buddypress.org/support/topic/display-username-in-members-directory/
then
the code that shows the user names is:
COPY CODEfunction render_bp_meta() { global $kleo_config; $output = array(); if (get_member_age(bp_get_member_user_id())) { $output['age'] = apply_filters('kleo_bp_meta_after_age', get_member_age(bp_get_member_user_id())); } //fields to show $fields_arr = $kleo_config['bp_members_loop_meta']; //user private fields $private_fields = array(); if (function_exists('bp_xprofile_get_hidden_fields_for_user')) { $private_fields = bp_xprofile_get_hidden_fields_for_user(bp_get_member_user_id()); } if (!empty($private_fields)) { //get the fields ids that will be displayed on members list if ( false === ( $fields_id_arr = get_transient( 'kleo_bp_meta_fields' ) ) ) { $fields_id_arr = array(); foreach ($fields_arr as $val) { if (get_profile_id_by_name($val)) { $fields_id_arr[$val] = get_profile_id_by_name($val); } } set_transient( 'kleo_bp_meta_fields', $fields_id_arr, 60*60*12 ); } if (!empty($fields_id_arr)) { //fields that will actually display $show_fields = array_diff($fields_id_arr, $private_fields); if (!empty($show_fields)) { $fields_arr_inv = array_flip($fields_id_arr); foreach ($show_fields as $key => $val): if(bp_get_member_profile_data( 'field='.$fields_arr_inv[$val] )): $output[] = bp_get_member_profile_data( 'field='.$fields_arr_inv[$val] ); endif; endforeach; } } } else { foreach ($fields_arr as $key => $val): if(bp_get_member_profile_data( 'field='.$val )): $output[] = bp_get_member_profile_data( 'field='.$val ); endif; endforeach; } $output = apply_filters('kleo_bp_meta_fields',$output); if (is_array($output)) { $output_str = '<p class="date">'. implode(" / ", $output).'</p>'; } else { $output_str = ''; } echo '<div class="search-meta">'; echo apply_filters('kleo_bp_members_dir_name','<h5 class="author"><a href="'. bp_get_member_permalink().'">'. bp_get_member_name().'</a></h5>'); echo $output_str; echo '</div>'; }
and replace
COPY CODEbp_get_member_name() /pre> with <pre> bp_core_get_username()
You just need to add the modified code with the new function in your functions.php file from your child theme.
Let me know if this works.
Thank you,
CatalinHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.