I promised this plugin when we had just launched BuddyDev. I got some time yesterday and here is the recent visitors plugin for you.
BuddyPress Recent Profile Visitors Plugin shows the most recent profile visitors on a user profile. The profile visiting recording can be turned on/turned off by a user.
Here is a screenshot to show how it looks.
If you don't want to show your visits to other user's profile, You can disable from the settings->Recent Visitors options as shown below
Please note, if you turn off the profile visits, It will not show you who visited your profile. I just wanted to make it fair enough, so it is mutual. If you want to see who visited your profile, keep the settings on. Once you turn the settings off, It will not record any data for you.
The settings are user specific.
How to Install
1. Download the plugin from here https://buddydev.com/plugins/recent-visitors-for-buddypress-profile/
2. Unzip recent-visitor-for-bp.zip
3. Upload recent-visitor-for-bp folder to wp-content/plugins
4. Go to Dashboard->Plugins->Installed and activate "Bp Recent Profile Visitors"
5. Let the plugin do its magic.
Alternatively, you can use Dashboard->Plugins->Add New, click on the upload tab and browse this zip file, upload and click activate, you are done.
How to Use
If you are using BuddyPress 1.2 default theme or the BuddyPress child theme for bp-default, The recent visitors are automatically displayed at the profile using the action hook "bp_after_member_header", otherwise, you can always call
It will list the most recent 5 visitors
Some example codes
// if you do not provide user id, it will show that for displayed user.
$total_unique_visitors = visitors_get_unique_visitors_count( $user_id );
// this returns total profile visits, which includes multiple visits by same user.
$total_profile_visit = visitors_get_profile_visit_count( $user_id );
// Get the $n most recent visitor of $user_id
// returns array of users, manipulate them as you wish.
$users = visitors_get_recent_visitors( $user_id = null, $count = 5 );
Hope you will like it 🙂 Looking forward to hear more for the enhancement.
NOTE: This is a premium plugin and only available to buddydev premium members.