Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ronalfy/1bf40ebf7b43b66e2acd84bfae862318 to your computer and use it in GitHub Desktop.
Save ronalfy/1bf40ebf7b43b66e2acd84bfae862318 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Invite Codes On Custom Account Page
<?php
/*
Show an invite code on the account page.
*/
function pmproio_custom_the_content_account_page($content)
{
global $current_user, $pmpro_pages, $post;
// First check if PMPro is active.
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return $content;
}
// Make sure invite addon is active.
if ( ! function_exists( 'pmproio_getInviteCodes' ) ) {
return $content;
}
if(!empty($current_user->ID) && is_page( 'your-page-slug' ) ) // Change the slug to your custom account page.
{
//make sure they have codes
$codes = pmproio_getInviteCodes($current_user->ID);
if(empty($codes))
return $content;
ob_start();
?>
<div id="pmproio_codes" class="pmpro_box clear">
<?php if(count($codes) == 1) { ?>
<h2><?php _e('Invite Code', 'pmpro_invite_only'); ?></h2>
<p><?php _e('Give this code to your invited member to use at checkout', 'pmpro_invite_only'); ?></p>
<?php } else { ?>
<h2><?php _e('Invite Codes', 'pmpro_invite_only'); ?></h2>
<p><?php _e('Give these codes to your invited members to use at checkout', 'pmpro_invite_only'); ?></p>
<?php } ?>
<?php echo pmproio_displayInviteCodes(); ?>
<h4><?php _e('Used Invite Codes', 'pmpro_invite_only'); ?></h4>
<?php echo pmproio_displayInviteCodes($current_user->ID, false, true);?>
</div>
<?php
$temp_content = ob_get_contents();
ob_end_clean();
$content = str_replace('<!-- end pmpro_account-profile -->', '<!-- end pmpro_account-profile -->' . $temp_content, $content);
}
return $content;
}
add_filter('the_content', 'pmproio_custom_the_content_account_page', 30, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment