BuddyDev

Search

Buddypress Recent Profile Visitors Plugin & roel

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #9135

    Hello,

    I want a function in functions.php) which allows you to use to display profile visitors only for connected members (authors or editors) ?*
    I also hope that this will be incorporated a new feature in the next version

    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 22211
    Brajesh Singh on #9136

    Hi Herve,
    Welcome to BuddyDev forums.

    Please allow me to post the code in an hour or two.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 22211
    Brajesh Singh on #9138

    Hi,
    I am sorry for the delay.
    I will need a little more time today as I am pushing an update to make it easier.

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #9139

    Hi,
    No urgency for me. Thanks 🙂
    I hope that you will soon insert it directly in the plugin
    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 22211
    Brajesh Singh on #9140

    Thank you.
    Yes, I am planning to have it in the plugin itself.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 22211
    Brajesh Singh on #9301

    Hi Herve,
    Thank you for the patience.
    I have updated the plugin now.
    https://buddydev.com/plugins/recent-visitors-for-buddypress-profile/

    It now allows 3 more things:-
    1. Exclude some of the roles from visit recording. For eaample, you can use it to hide the administrator’s visit to other profiles
    2. Disable plugin features( listing visitors, directory listing etc) completely for some of the roles.
    3. recording Policy:- The default recording only records when both the visitor and the displayed user has the recording enabled. You can change it to always to always record a visit if it is enabled for the displayed user.

    Here the code to enable the plugin only for author/contributor role.

    
    
    /**
     * 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; // show 10 visitors
    
    	$settings['recording_policy'] = 'always';//always record
    
    	$included = array('author',  'editor' ); // only for author/editor
    
    	$all_roles = array_keys( wp_roles()->get_names() );
    
    	$settings['roles_excluded'] = array_diff($all_roles, $included );
    
    	return $settings;
    }
    
    add_filter( 'bp_visitors_settings', 'devb_custom_settings_for_recent_visitors' );
    

    Hope that helps.

You must be logged in to reply to this topic.

This topic is: not resolved