Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is a statement for the membership 2 pro which outputs the member subscription type. How can I wrap it with a Buddypress filter/hook to be able to use it on the members profiles?


PHP
if ( function_exists('bp_displayed_user_id') && class_exists('Membership_Plugin') && class_exists('Membership_Model_Subscription') ) {
$user_id = bp_displayed_user_id();
$user = Membership_Plugin->factory()->get_member($user_id);
$subs = $user->get_subscription_ids();

if ( is_array($subs) ) {
    $sub = array_pop($subs);
    $subscription = new Membership_Model_Subscription($sub));
    echo $subscription->sub_name();
   }
}


If the above snippet is inserted into the member-header.php in a loop, it breaks the page. So what is the correct way to process it for it to function properly?

Help is much appreciated!

Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900