Forked from andrewlimaza/shortcode_membership_name.php
Last active
September 4, 2018 11:52
-
-
Save travislima/5ed0282810ad9abf24ab6f2cd4fde145 to your computer and use it in GitHub Desktop.
Membership level name shortcode for Paid Memberships Pro
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 //Do not copy this tag. | |
// Copy the function below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
// Use the shortcode [membership_level] to display the user's current membership level. | |
function pmpro_membership_level_shortcode( $atts ){ | |
if(is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel()){ | |
global $current_user; | |
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); | |
return sprintf(__( "Your current level is: %s", "pmpro" ), $current_user->membership_level->name); | |
}else{ | |
return __( "You do not have a level", "pmpro" ); | |
} | |
} | |
add_shortcode( 'membership_level', 'pmpro_membership_level_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment