BuddyDev

Recent Visitors For BuddyPress Profile

BuddyPress Recent Profile Visitors Plugin shows the most recent profile visitors on a user profile as well as the most popular users on a BuddyPress site.

If you are looking for:-

  • Allowing users to see who visited their profile recently on BuddyPress social network
  • And/or Listing the most popular users on your BuddyPress site

Then the BuddyPress Recent Profile visitors  is the most suitable solution.

Features:-

  • The plugin records users who viewed profiles recently
  • Based on your settings, a user can see who viewed their profile
  • You can show the most popular users on your site over a period of time. For example, you can list top 10 users on your BuddyPress site over last 30 days(or 7 days etc)
  • You can also turn on/off the plugin(using code) for users based on roles. For example, you may charge users (Using any of the subscription plugin) and based on their status, you can use a small snnipet of code to show/hide the recent visitors.
  • The plugin comes with widget for most popular BuddyPress users as well as shortcodes for listing the most popular users on BuddyPress site, recently visiting user for a given user(or logged in)
  • The plugin also lists the most recent visitors of a user on his profile, in the members directory( a new tab) and if enabled, with a new component on profile(where user can see who visited them in last 7 days, 30 days and all time).
  • All the plugin features can be turned off easily(Please see the bottom of this page)

The profile visiting recording can be turned on/turned off by a user. It is also possible to exclude users belonging to some roles from recording. The whole feature can be turned on/off based on roles( please see code example section). The recent visitors can also be enabled as a tab and a shortcode is also available to display the recent visitors list anywhere.

Screenshots:-

 

When the profile visit is turned off, It will not show the user who visited their profile. The visits display must be mutual,  if a user want to see who visited their profile, they should keep the settings on. Once the user turns the settings off, It will not record any data for them. As a site admin, you can override this behaviour.

Documentation:-

Installation:-

1. Download the plugin
2. Unzip recent-visitors-for-buddypress-profile-xyz.zip
3. Upload recent-visitors-for-buddypress-profile to wp-content/plugins
4. Go to Dashboard->Plugins->Installed and activate "BuddyPress Recent Profile Visitors"
5. Let the plugin do its magic.
Alternatively, you can use wp-admin->Plugins->Add New, click on the upload tab and browse this zip file, upload and click activate, you are done.

Upgrading:-

We suggest using BuddyDev Dashboard plugin to allow automatic upgrade.

Using the Most Visited Users widget:-

Please visit Appearance->Widget and Add the "Most Visited Users" widget to your desired widget area.

The widget provides following options:-

BuddyPress Most visited users widget options

You can select the view to be slider or the default list. View count can be shown beside the users.

 

Using Shortcode:-

The plugin provides two shortcodes

  • [bp-visitors-most-visited-users] to list most visited/popular users.
  • [bp-visitors-recent-visitors] to list the recent visitors to a specific user.

Showing most popular users using the shortcode:-

You can use the [bp-visitors-most-visited-users] shortcode to show the most popular users on your site. The shortcode provides following options:-

  • view:- 'slide' or 'list'
  • max:- int, how many entries at most to show.
  • duration:- int, for how many days
  • show_visits:- 1 or 0, do you want to show the view count for the profiles.

Example:- Show the most popular users for the last 7 days in slide view.

[bp-visitors-most-visited-users view="slide" max="5" duration="7" show_visits="0"]

Showing recent visitors using shortcode:-

You can use the shortcode [bp-visitors-recent-visitors] to show the list of recent visitors. By default, It shows 5 recent visitors of the logged in user. The shortcode provides following options:-

  • user :- It can be username (like sbrajesh, or email like someone@example.org or user Id). If this user exists, It will list the visitors of this user. By default, It is set to current logged in user.
  • max:- It is the maximum no. of visitors to show. default is 5.
  • duration:- You can set the maximum no. of days to take in account. default is set to 0. It means all time. You can set it to 7  to show the recent visitors in last 7 days.

Example:-

[bp-visitors-recent-visitors user=sbrajesh max=20 duration=7]

The above shortcode will display 20 most recent visitors in the last 7 days for the user sbrajesh.

 

Modifying the plugin settings:-

With version 1.5.0 and above, you do not need to touch any code. Please use the admin panel. If you are upgrading from an older version to 1.5.0 and have used the custom code earlier, we suggest removing the custom code for better experience with the admin panel.

You can filter on 'bp_visitors_settings' to modify the settings(Only use if you are using an older version, we will remove the filter or rename it in 1.5.1).

Here is an example to show 10 recent visitors in the list.

add_filter( 'bp_visitors_settings', 'devb_custom_settings_for_recent_visitors' );
/**
 * Filter Settings
 *
 * @param mixed $settings
 * @return array
 */
function devb_custom_settings_for_recent_visitors( $settings ) {

	/**
	 * Settings is an associative array and has following values
	 * See Exampel of allowed settings in the commented section below
	 */

	/*
	$default = array(
		//no. of visitors to display
		'max_display'              => 5,
		//0 means all time, 7 means 7 days, 30 means 30 days
		'duration'                 => 0,
		//show the recent visitor as component?
		'add_screen'               => false,
		//true then displays in member header, false means does not display in member header
		'show_in_header'           => true,
		// true then show the Recent visitors tab in Members Directory screen for logged in users, false means no tab in directory.
		'show_in_directory'        => true,
		//should we enable local notification for user setting?
		'notification_local'       => false,
		//should we enable settings for the receiving the notification by email?
		'notification_by_email'    => false,
		//by default local notification is disabled, set it to 'yes' for it being enabled for the user
		'notify_visitors_locally'  => 'no',
		// By default disable the receiving notification by email settings for user, set it to 'yes'
		'notify_visitors_by_email' => 'no',
		//what should be the  default user avatar size
		'default_avatar_size'      => 32,
		//should the user be able to st their own preference in profile->settings screen?
		'allow_user_settings'      => true,
		// Never record visits by users belonging to these roles
		'recording_roles_excluded' => array(),
		// disable the plugin feature for these roles
		// These user's won't be able to see their own visitors
		'roles_excluded'           => array(), // array('subscriber', 'contributor')
		// Recording policy. Should we record when both the users have it enabled ot not.
		// 'always'= For recording visit of the user_id, do not check whether they have it enabled or not.
		// 'mutual'= only record if enabled by the visitor,
		'recording_policy'         => 'mutual',
	);
	*/

	// Selectively update one or more settigs

	$settings['max_display'] = 10; //sow 10 visitors

	return $settings;
}

 

Most of the BuddyPress theme will automatically display the recent visitors using   the action hook "bp_after_member_header", If your theme does not display it(  make sure someone has visited your profile before the conclusion)  you can always call

visitors_show_my_recent_visitor();

It will list the most recent 5 visitors.

Code snippets:-

Some example codes:-

$total_unique_visitors = visitors_get_unique_visitors_count( $user_id );//if you  do not  provide user id, it will show that for displayed user

//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

$users = visitors_get_recent_visitors( get_current_user_id(), $count = 5 );
//above line returns an array of visitor object

BuddyBoss Notes:-

The plugin settings 'Enable local notification?' and 'Email Notification?' will no longer supported in BuddyBoss version greater than '1.9.3'.
These settings now available in BuddyBoss > Settings > Notification > Notification Types > Recent Visitors

Release History

  • Version: 1.8.5

    Wednesday, 11 September, 2024
    • Tested With: BuddyPress 14.0.0
    • Compatible With: BuddyPress 8.0+

    Fixes count display issue with BP Nouveau template pack.

  • Version: 1.8.4

    Friday, 30 August, 2024
    • Tested With: BuddyPress 14.0
    • Compatible With: BuddyPress 8.0+

    Update plugin header to remove required plugins info

  • Version: 1.8.3

    Tuesday, 27 August, 2024
    • Tested With: BuddyPress 14.0
    • Compatible With: BuddyPress 8.0+

    Update plugin header info i.e. plugin url and requires plugin list

  • Version: 1.8.2

    Friday, 17 May, 2024
    • Tested With: BuddyPress 12.5.0
    • Compatible With: BuddyPress 8.0+

    Added support for BuddyBoss custom notification API
    Bug fix directory tab count in BuddyBoss

  • Version: 1.8.1

    Tuesday, 20 February, 2024
    • Tested With: BuddyPress 12.2.0
    • Compatible With: BuddyPress 8.0+

    Bumping version to regenerate archive for WordPress 6.4.3 compatibility.

  • Version: 1.8.0

    Thursday, 21 December, 2023
    • Tested With: BuddyPress 12.0
    • Compatible With: BuddyPress 8.0+

    Added compatibility with BuddyPress 12.0

  • Version: 1.7.1

    Friday, 31 March, 2023
    • Tested With: BuddyPress 11.1.0
    • Compatible With: BuddyPress 8.0+

    Fixed issue of showing tab when mutual recording policy is enabled and the user disables their recording.

  • Version: 1.7.0

    Friday, 27 January, 2023
    • Tested With: BuddyPress 11.0
    • Compatible With: BuddyPress 8.0+

    Added support for BuddyBoss Theme version 2
    Fix notices of template for version 1 of BuddyBoss

  • Version: 1.6.9

    Monday, 29 November, 2021
    • Tested With: BuddyPress 10.3.0
    • Compatible With: BuddyPress 8.0+

    Mark notification as read when user click on recent visitor notification

  • Version: 1.6.8

    Monday, 22 November, 2021
    • Tested With: BuddyPress 9.1.1
    • Compatible With: BuddyPress 8.0+

    Added support for BuddyBoss specific markup for settings.

  • Version: 1.6.7

    Tuesday, 08 June, 2021
    • Tested With: BuddyPress 9.0.0
    • Compatible With: BuddyPress 7.0+

    Fixed the visibility of the Visitors nav for disabled roles. The screen was not viewable but nav was visible. This update fixes that.

  • Version: 1.6.6

    Friday, 26 March, 2021
    • Tested With: BuddyPress 7.2.1
    • Compatible With: BuddyPress 6.0+

    Remove action buttons from visitors list on BuddyBoss platform. Fixes link not working.

  • Version: 1.6.5

    Wednesday, 24 March, 2021
    • Tested With: BuddyPress 7.2.1
    • Compatible With: BuddyPress 6.0+

    Add better compat with BuddyBoss members listing. removes the buttons.

  • Version: 1.6.4

    Tuesday, 28 July, 2020
    • Tested With: BuddyPress 6.0
    • Compatible With: BuddyPress 4.0+

    Fix shortcode bug

  • Version: 1.6.3

    Saturday, 16 May, 2020
    • Tested With: BuddyPress 6.0
    • Compatible With: BuddyPress 4.0+

    Fix the filter for showing component tabs.
    Fix duplicate email template creation(on reactivation) when the admin changed contents of email.

  • Version: 1.6.2

    Thursday, 07 May, 2020
    • Tested With: BuddyPress 5.2
    • Compatible With: BuddyPress 4.0

    remove deleted users from the visitors list. The counts are eventually consistent after transient expires(at most 60 minutes).

  • Version: 1.6.1

    Sunday, 26 April, 2020
    • Tested With: BuddyPress 5.2
    • Compatible With: BuddyPress 4.0

    Added Recent visitors widget.
    Added option to disable notification for repeated visits.
    Added a filter to show profile component as needed.

  • Version: 1.6.0

    Wednesday, 04 March, 2020
    • Tested With: BuddyPress 5.1.2
    • Compatible With: WordPress 4.0+

    Add support for overriding the markup via template override

  • Version: 1.5.6

    Monday, 18 November, 2019
    • Tested With: BuddyPress 5.0
    • Compatible With: BuddyPress 3.0+

    minor update to add a filter for settings page visibility

  • Version: 1.5.5

    Saturday, 27 July, 2019
    • Tested With: BuddyPress 5.0
    • Compatible With: BuddyPress 2.5+

    Added email template. Now site admin can modify email format from "Emails menu" in the backend.