Created
August 30, 2015 23:31
-
-
Save JudeRosario/ed3f94a20123921db76b to your computer and use it in GitHub Desktop.
Get Membership Name for current user
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
add_shortcode( 'membership_name', 'membership_name_func' ); | |
function membership_name_func() { | |
// User ID | |
$user = get_current_user_id(); | |
// Membership ID to Membership Object | |
$member = MS_Factory::load( 'MS_Model_Member', $user ); | |
$membership_id = $member->get_membership_ids(); | |
$membership = MS_Factory::load( 'MS_Model_Membership', current($membership_id) ); | |
return $membership->name ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.
Then in the template / page / post simply add
[membership_name]
as a shortcode and you are done.