Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/02d18abc9e74e5f619939fb4fd669876 to your computer and use it in GitHub Desktop.
Save ipokkel/02d18abc9e74e5f619939fb4fd669876 to your computer and use it in GitHub Desktop.
Display HTML above the PMPro checkout form based on the user's membership level.
<?php
/**
* This recipe displays HTML above the checkout form based on the user's membership level.
*
* 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 my_pmpro_checkout_before_form() {
if ( ! pmpro_hasMembershipLevel() ) {
?>
<div>This user is does not have a membership level</div>
<img alt="image for non-members" src="non-member.png" />
<?php
} elseif ( pmpro_hasMembershipLevel( 2 ) ) {
?>
<div>This user is a member of level 2</div>
<img alt="image for level 2" src="level2.png" />
<?php
}
}
add_action( 'pmpro_checkout_before_form', 'my_pmpro_checkout_before_form' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment