How it Works
Allow members and users to view information about their Membership in a card-like format via the website or print. The card displays specific user and membership data as defined by shortcode attributes and can be extended with custom code.
- You can display one or more of the user’s membership levels on the card (v1.0+ is compatible with the Multiple Memberships Per User Add On).
- Info on the card can be customized by shortcode attributes (documented below).
- You can add an icon or logo to the card for personalization.
- The card can display a scannable QR Code, which you can update via a filter to adjust what data is returned by the QR code.
- Members will see a link to view their Membership Card from the “Member Links” section of the Membership Account page.
- Users will see a link to view their Membership Card on the “Edit Profile” page.
- Plus and Unlimited members can install the add on via the Memberships > Add Ons admin page.
- Or, download the plugin file and upload the ‘pmpro-membership-card’ directory to the ‘/wp-content/plugins/’ directory of your site.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- Create a page and add the shortcode
- (Optional) Customize your card by adjusting shortcode attributes, setting a featured image or creating a custom template.
Using the Shortcode
The plugin adds a new shortcode which assigns a page as the Membership Card page. The page containing the shortcode will display the membership card and a link to print the membership card.
Shortcode attributes include:
- print_size: Specify what sizes to include in the “print” view; Default: all; Accepts: “small”, “medium”, “large” and/or “all”.
- qr_code: Optionally display a QR code on the card. Default: “false”; Accepts: “true” or “false”.
- qr_data: Specify what data the scanned QR code should return. Default: “ID”; Accepts: “email”, “ID”, “level” or “other”. If set to “other”, you must leverage the
pmpro_membership_card_qr_data_otherfilter hook to set the value.
If Paid Memberships Pro is activated, only members will be able to view the membership card. If not, the card will show for all WP users.
Adding an Image to the Card
You can add an icon or logo to the card by setting a “Featured Image” on the page that displays your membership card. Please follow this WordPress guide for adding a featured image to a page. You can also optionally show the user avatar on the card using the code recipe provided in this tutorial.
Custom Template for the Membership Card
If you need to deeply customize the Membership Card in a way that shortcode attributes, custom CSS, or provided action and filter hooks allow, you will need to create a custom template for the card. You can create your own custom Membership Card format and load it via a specific location in your theme. Copy the file located at:
/pmpro-membership-card/templates/membership-card.php to your active theme directory in this exact location:
.../themes/my-theme/membership-card.php. This will load your custom template in place of the default template.
Action and Filter Hooks
apply_filters( 'pmpro_membership_card_since_date', string $since_date );
The default behavior will show the “user_registered” date (the date the user registered for the site).
do_action( 'pmpro_membership_card_after_card' );
Hook to show additional content via a custom function.
apply_filters( 'pmpro_membership_card_qr_code_size', string $size );
The default QR code value is set to “125×125”.
apply_filters( 'pmpro_membership_card_qr_data_other', object $pmpro_membership_card_user, string $option );
Allows you to show custom information when the shortcode’s
qr_dataattribute is set to ‘other’.