Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save toluaddy/2b472daf71a82ceb810b068030c14337 to your computer and use it in GitHub Desktop.
Save toluaddy/2b472daf71a82ceb810b068030c14337 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