Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Integrate Membership Card with Invite Only Member Add On [Paid Memberships Pro]
<?php
/**
* Set the QR code to link to a checkout with an invite code when someone scans a Q.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_membership_card_qr_invite_code( $card_user, $option ) {
global $pmproio_invite_required_levels;
if ( $option == 'other' ) {
$codes = get_user_meta($card_user->ID, 'pmpro_invite_code', true);
if ( ! $codes ) {
return ''; //Change this to return default value for members that don't have invite codes.
}
$code = '';
if ( is_array( $codes ) ) {
$code = $codes[0];
} else {
$code = $codes;
}
// Default checkout ID if no required_levels is found.
$checkout_id = 1;
if ( is_array( $pmproio_invite_required_levels ) && ! empty( $pmproio_invite_required_levels[0]) ) {
$checkout_id = $pmproio_invite_required_levels[0];
}
return pmpro_url( 'checkout', '?level=' . $checkout_id . '&invite_code=' . $code, "https" );
}
}
add_filter( 'pmpro_membership_card_qr_data_other', 'my_pmpro_membership_card_qr_invite_code', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.