BuddyPress Limit Friendship - Discontinued

This plugin has been deprecated in favour of BuddyPress Friendship Restrictions. Please use BuddyPress Friendship restrictions.

BuddyPress Limit Friendship plugin allows site owners to limit the number of friends a user can have on their network. It does so based on the 2 criteria.

The criteria are:-

  • Number of Existing Friends
  • Number of Existing Friends + Number of Pending Friendship Request Sent & Received
Here is the admin screen(You can see it by going to settings->BuddyPress->Settings)

When you select the criteria as No. of existing Friends, The plugin only checks for existing friends count(for both the users) and will limit the user to be added as friend or to add a new friend if they have
When you select the criteria as No. Of existing Friends + Friendship Requests, the plugin will check for both the users that they don't have crossed the limit(The sum of Friendship Requests sent, which is pending; The friendship requests received  which is not approved and the total no. of exiting friends is less than the allowed limit for both the users).

This plugin is also compatible with our Extended Friendship request plugin.

Here is an example of what happens when a user tries to add new friend.

The best use case will be to use this plugin in a membership based site and ask users to upgrade account for more friends or to use it as a tool for spam control(Do not allow too many friends quickly).

For now, I have allowed users to accept any pending request they already have even if the limit is over. Please do let me know if you  want that and I will include it.

Customizing Allowed Friendship Count based on WordPress Roles:-

You can use the following code to add custom limit based on roles/capabilities

 * Limit BuddyPress friendship based on WordPress roles
 * @param int $count how many
 * @param int $user_id for the given user.
 * @return int allowed no. of friends
function buddydev_limit_friendship_count_based_on_role( $count, $user_id ) {

	if ( user_can( $user_id, 'manage_options' ) ) {
		//site admin
		$count = 100; // 100 friends allowed
	} elseif (  user_can( $user_id, 'moderate_comments' ) ) {

	} elseif ( user_can( $user_id, 'edit_published_posts' ) ) {

	} elseif ( user_can( $user_id, 'read' ) ) {

		$count = 3; // only 3 allowed for subscribers

	return $count;
add_filter( 'bp_limit_friendship_count', 'buddydev_limit_friendship_count_based_on_role', 10, 2 );

Please put the code in bp-custom.php to make it work. You can also customize the limit based on BuddyPress member types.

Release History

  • Version: 1.0.4

    Wednesday, 14 February, 2018
    • Tested With: BuddyPress 2.9.3
    • Compatible With: BuddyPress 2.5+

    Fix the static call notice
    Released on: 06/18/2017
    Last tested: 02/14/2018

  • Version: 1.0.3

    Saturday, 08 April, 2017
    • Tested With: BuddyPress 2.8.2
    • Compatible With: BuddyPress 2.5+

    Updated to limit on acceptance of friendship too.

  • Version: 1.0.2

    Thursday, 29 December, 2016
    • Tested With: BuddyPress 2.7.4
    • Compatible With: BuddyPress 2.2+

    Super admin can send any number of request to anyone

  • Version: 1.0.1

    Monday, 01 August, 2016
    • Tested With: BuddyPress
    • Compatible With: BuddyPress 2.2+

    Complete rewrite.
    Fixed bug which counted the confirmed friends twice when the strategy was set to request.

  • Version: 1.0

    Tuesday, 12 May, 2015
    • Tested With: BuddyPress 2.3.0
    • Compatible With: BuddyPress 1.7+/BudddyPress1.8

    Initial release