Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarrydLong/76b2587ecb2eaaee42ecd311efaf160d to your computer and use it in GitHub Desktop.
Save JarrydLong/76b2587ecb2eaaee42ecd311efaf160d to your computer and use it in GitHub Desktop.
<?php
/**
* This code recipe will create a shortcode that returns an image based on the level selected.
*
* 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 mypmpro_membership_checkout_image(){
if( !empty( $_REQUEST['level'] ) ){
$level = intval( $_REQUEST['level'] );
if( $level == 1 ){
$image_url = 'ADD FULL URL TO IMAGE HERE';
} else if( $level == 2 ){
$image_url = 'ADD DIFFERENT FULL URL TO IMAGE HERE HERE';
} else {
$image_url = 'ADD DEFAULT URL TO IMAGE HERE';
}
return "<div class='mypmpro_membership_checkout_image'><img src='$image_url' /></div>";
}
}
add_shortcode( 'membership_checkout_image', 'mypmpro_membership_checkout_image' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment