Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Created December 6, 2015 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JudeRosario/a409c752323a4cc594a9 to your computer and use it in GitHub Desktop.
Save JudeRosario/a409c752323a4cc594a9 to your computer and use it in GitHub Desktop.
M2 + BuddyPress Badges - Copy/Paste
add_action( 'bp_member_header_actions', 'membership_2_labels_bp' );
function membership_2_labels_bp() {
$api = ms_api();
$user_id = bp_displayed_user_id() ;
$member = MS_Factory::load( 'MS_Model_Member', $user_id );
foreach ( $member->subscriptions as $subscription ) {
if ( ! $member->has_membership( $subscription->membership_id ) ) {
continue;
}
$membership = $subscription->get_membership();
echo '<div class="memberhip-label" style="background:#B55849;color:white;text-align:center;border-radius:2px;">'.
$membership->name.
'</div>';
}
}
@JudeRosario
Copy link
Author

Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.

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