Last active
September 17, 2022 08:16
-
-
Save kimcoleman/9f34262bf9b1e6e79ef4ebdf500bc76a to your computer and use it in GitHub Desktop.
Add a new tab to your BuddyPress Profile page to show a user's Membership Account information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a new tab to your BuddyPress Profile page to show a user's Membership Account information. | |
* | |
*/ | |
function pmpro_membership_buddypress_tab() { | |
global $bp; | |
if ( function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel() ) { | |
bp_core_new_nav_item( array( | |
'name' => __( 'Membership', 'pmpro' ), | |
'slug' => 'membership', | |
'position' => 100, | |
'parent_url' => bp_loggedin_user_domain() . '/membership/', | |
'parent_slug' => $bp->profile->slug, | |
'screen_function' => 'pmpro_buddypress_membership', | |
'show_for_displayed_user' => false, | |
'item_css_id' => 'pmpro_buddypress_membership', | |
'default_subnav_slug' => 'membership' | |
) ); | |
} | |
} | |
add_action( 'bp_setup_nav', 'pmpro_membership_buddypress_tab', 1000 ); | |
// screen_function for Membership tab in BuddyPress Profile. | |
function pmpro_buddypress_membership () { | |
add_action( 'bp_template_title', 'pmpro_buddypress_membership_title' ); | |
add_action( 'bp_template_content', 'pmpro_buddypress_membership_content' ); | |
bp_core_load_template( 'buddypress/members/single/plugins' ); | |
} | |
// Title displayed on Membership tab in BuddyPress Profile. | |
function pmpro_buddypress_membership_title() { | |
_e( 'Membership', 'pmpro' ); | |
} | |
// Content displayed on Membership tab in BuddyPress Profile. | |
function pmpro_buddypress_membership_content() { | |
echo do_shortcode('[pmpro_account]'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Add Membership Account Information to Your Member’s BuddyPress Profile" at Paid Memberships Pro here: https://www.paidmembershipspro.com/add-membership-account-information-to-your-members-buddypress-profile/