Created
July 6, 2021 13:53
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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