Forked from andrewlimaza/show_member_number_on_card.php
Last active
April 4, 2021 03:26
-
-
Save travislima/939e52d580db481d73f491046e68d872 to your computer and use it in GitHub Desktop.
Display the Unique Member Number on Membership Card Add On Paid Memberships Pro
This file contains 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 | |
/** | |
* This will show a member number on the membership card for Paid Memberships Pro. Please read all comments below! | |
* This requires the following - https://www.paidmembershipspro.com/generate-a-unique-member-number-for-display-on-membership-account-confirmation-email-and-more/ | |
* At the time of this writing, created a custom page template and added in hook "do_action( 'pmpro_membership_card_additional_fields', $pmpro_membership_card_user );" to the relevant area. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Reach out to the PMPro Support team for help with this code recipe - https://www.paidmembershipspro.com/support/ | |
*/ | |
function my_show_member_number_on_card( $user ) { | |
if( !pmpro_hasMembershipLevel() ) { | |
return; | |
} | |
$member_id = get_user_meta( $user->ID, 'member_number', true ); | |
if( empty( $member_id ) ) { | |
// lets generate it on the fly. | |
$member_id = generate_member_number( $user->ID ); | |
} | |
echo '<p><strong>Membership Number:</strong> ' . $member_id . '</p>'; | |
} | |
add_action( 'pmpro_membership_card_additional_fields', 'my_show_member_number_on_card' ); |
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 "Display a Unique Membership Number on your Member’s List, Membership Directory, and Membership Card." at Paid Memberships Pro here: https://www.paidmembershipspro.com/display-a-unique-membership-number-on-your-members-list-membership-directory-and-membership-card/