Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wbcomdev/b4b575f90d51b85e461c082d17229e4e to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/b4b575f90d51b85e461c082d17229e4e to your computer and use it in GitHub Desktop.
<?php
/**
* Bp_profile_views_member_loop_modification
*
* @return void
*/
function wbbp_display_profile_views_at_member_loop() {
global $wpdb;
$user_id = bp_get_member_user_id();
$component = bp_current_component();
if ( 'members' === $component ) {
$views = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM `' . $wpdb->prefix . 'bp_profile_views` WHERE `user_id`= %d', $user_id ), ARRAY_A );
if ( count( $views ) > 0 ) {
$view_count = count( $views );
echo sprintf(
'<span class="member-directory-profile-view"> %s : ( %d ) </span>',
esc_html__( 'Views', 'bp-profile-views' ),
$view_count,
);
}
}
}
add_action( 'bp_directory_members_item_meta', 'wbbp_display_profile_views_at_member_loop', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment