Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active September 7, 2023 19:34
Show Gist options
  • Save JarrydLong/749a5d4aa3edb71afa0412e7eef1a478 to your computer and use it in GitHub Desktop.
Save JarrydLong/749a5d4aa3edb71afa0412e7eef1a478 to your computer and use it in GitHub Desktop.
<?php
/**
* This recipe will return a member number when scanning a QR code.
*
* Set your shortcode to [pmpro_membership_card qr_code='true' qr_data='other']
* for this filter to take effect.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function mypmro_membership_card_return_member_number( $pmpro_membership_card_user, $option ){
//Checking if PMPro is active
if( !function_exists( 'pmpro_hasMembershipLevel' ) ){
return;
}
if( $option == 'other' ){
$member_number = get_user_meta( $pmpro_membership_card_user->ID, 'member_number', true );
if( $member_number !== "" ){
return $member_number;
}
}
}
add_filter( 'pmpro_membership_card_qr_data_other', 'mypmro_membership_card_return_member_number', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment