Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Last active May 24, 2024 15:23
Show Gist options
  • Save kimcoleman/51953b44607ac36aca7b6356aeb1aded to your computer and use it in GitHub Desktop.
Save kimcoleman/51953b44607ac36aca7b6356aeb1aded to your computer and use it in GitHub Desktop.
This code will display the member badge on the BuddyPress Profile page using the bp_before_member_header_meta hook.
<?php
/**
* my_pmpro_member_badge_display This code will display the member badge on the BuddyPress Profile page using the bp_before_member_header_meta hook.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function my_pmpro_member_badge_display( ) {
if ( function_exists( 'pmpromb_show_badge' ) && function_exists( 'pmpro_hasMembershipLevel' ) ) {
if ( pmpro_hasMembershipLevel( array( '1', '2' ), bp_displayed_user_id() ) ) {
pmpromb_show_badge( bp_displayed_user_id() );
}
}
}
add_action( 'bp_before_member_header_meta', 'my_pmpro_member_badge_display' );
@kimwhite
Copy link

It is possible to add the badge to thete members pages also using this function:
add_action( 'bp_directory_members_item', 'my_pmpro_member_badge_display' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment