Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active February 3, 2020 12:06
Show Gist options
  • Save andrewlimaza/b54f553148c2a329a8f803b228802359 to your computer and use it in GitHub Desktop.
Save andrewlimaza/b54f553148c2a329a8f803b228802359 to your computer and use it in GitHub Desktop.
hide 'Add Friend' in BuddyPress when a user does not have an active membership with Paid Memberships Pro.
<?php
/**
* Hide 'Add Friend' button in BuddyPress if a user does not have an active membership level.
* Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com
*/
function pmpro_hide_add_friend_if_non_member( $button ) {
if ( pmpro_hasMembershipLevel() ) { //if the user has a membership level, show the 'add friend button'.
return $button;
}
return "";
}
add_filter( 'bp_get_add_friend_button', 'pmpro_hide_add_friend_if_non_member' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment