Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active October 2, 2025 09:29
Show Gist options
  • Save JarrydLong/c78d0147de0386ecb38a151aa4ea7df6 to your computer and use it in GitHub Desktop.
Save JarrydLong/c78d0147de0386ecb38a151aa4ea7df6 to your computer and use it in GitHub Desktop.
<?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 );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Create a Custom Membership Card for WordPress Users and Members to Print or View Online" at Paid Memberships Pro here: https://www.paidmembershipspro.com/customize-membership-card-wordpress/

@hamdan-Deb
Copy link

hamdan-Deb commented Apr 11, 2021

? @laurenhagan0306 @JarrydLong @andrewlimaza
How can we email the "generated Card with QR" to Client.

@andrewlimaza
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment