SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /* Members meta on members listing */
  3. add_action( 'bp_members_meta', 'render_bp_meta' );
  4.  
  5. if ( ! function_exists( 'render_bp_meta' ) ):
  6.     function render_bp_meta() {
  7.         global $kleo_config;
  8.         $output = array();
  9.  
  10.         if ( get_member_age( bp_get_member_user_id() ) ) {
  11.             $output['age'] = apply_filters( 'kleo_bp_meta_after_age', get_member_age( bp_get_member_user_id() ) );
  12.         }
  13.         //fields to show
  14.         $fields_arr = $kleo_config['bp_members_loop_meta'];
  15.  
  16.  
  17.         //user private fields
  18.         $private_fields = array();
  19.         if ( function_exists( 'bp_xprofile_get_hidden_fields_for_user' ) ) {
  20.             $private_fields = bp_xprofile_get_hidden_fields_for_user( bp_get_member_user_id() );
  21.         }
  22.         if ( ! empty( $private_fields ) ) {
  23.             //get the fields ids that will be displayed on members list
  24.             if ( false === ( $fields_id_arr = get_transient( 'kleo_bp_meta_fields' ) ) ) {
  25.  
  26.                 $fields_id_arr = array();
  27.  
  28.                 foreach ( $fields_arr as $val ) {
  29.                     if ( get_profile_id_by_name( $val ) ) {
  30.                         $fields_id_arr[ $val ] = get_profile_id_by_name( $val );
  31.                     }
  32.                 }
  33.  
  34.                 set_transient( 'kleo_bp_meta_fields', $fields_id_arr, 60 * 60 * 12 );
  35.             }
  36.             if ( ! empty( $fields_id_arr ) ) {
  37.                 //fields that will actually display
  38.                 $show_fields = array_diff( $fields_id_arr, $private_fields );
  39.                 if ( ! empty( $show_fields ) ) {
  40.                     $fields_arr_inv = array_flip( $fields_id_arr );
  41.  
  42.                     foreach ( $show_fields as $key => $val ):
  43.                         if ( @bp_get_member_profile_data( 'field=' . $fields_arr_inv[ $val ] ) ):
  44.                             $output[] = bp_get_member_profile_data( 'field=' . $fields_arr_inv[ $val ] );
  45.                         endif;
  46.                     endforeach;
  47.                 }
  48.             }
  49.         } else {
  50.             foreach ( $fields_arr as $key => $val ) {
  51.                 if ( @bp_get_member_profile_data( 'field=' . $val ) ) {
  52.                     $output[] = bp_get_member_profile_data( 'field=' . $val );
  53.                 }
  54.             }
  55.         }
  56.  
  57.         $output = apply_filters( 'kleo_bp_meta_fields', $output );
  58.         if ( is_array( $output ) ) {
  59.             $output_str = '<p class="date">' . implode( " | ", $output ) . '</p>';
  60.         } else {
  61.             $output_str = '';
  62.         }
  63.         echo '<div class="search-meta">';
  64.         echo apply_filters( 'kleo_bp_members_dir_name', '<h5 class="author"><a href="' . bp_get_member_permalink() . '">' . bp_get_member_name() . '</a></h5>' );
  65.         echo $output_str;
  66.         echo '</div>';
  67.     }
  68. endif;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top