Last active
October 2, 2025 09:29
-
-
Save JarrydLong/c78d0147de0386ecb38a151aa4ea7df6 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* This recipe will check if a member has an active level associated with | |
* their account. It will add either 'active' or 'inactive' to QR code's data. | |
* | |
* 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_show_active( $pmpro_membership_card_user, $option ){ | |
//Checking if PMPro is active | |
if( !function_exists( 'pmpro_hasMembershipLevel' ) ){ | |
return; | |
} | |
if( $option == 'other' ){ | |
//Change according to the levels you'd like to check for | |
$has_level = pmpro_hasMembershipLevel( array( 1, 2, 3 ) ); | |
if( $has_level ){ | |
return 'active'; | |
} else { | |
return 'inactive'; | |
} | |
} | |
} | |
add_filter( 'pmpro_membership_card_qr_data_other', 'mypmro_membership_card_show_active', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hamdan-Deb you may download (print it to PDF) then email. I recommend reaching out to our support channel as we don't monitor gists for support requests.
Thanks!