Last active
June 23, 2022 07:22
-
-
Save wbcomdev/b4b575f90d51b85e461c082d17229e4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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