Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created October 9, 2020 10:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/be0c5abe8e927b0a9a68472882e30b50 to your computer and use it in GitHub Desktop.
Save andrewlimaza/be0c5abe8e927b0a9a68472882e30b50 to your computer and use it in GitHub Desktop.
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