Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active February 19, 2019 23:24
Show Gist options
  • Save andrewlimaza/2fce24d79e51fecafbf5c94d0629c2bc to your computer and use it in GitHub Desktop.
Save andrewlimaza/2fce24d79e51fecafbf5c94d0629c2bc to your computer and use it in GitHub Desktop.
Display members information example for Paid Memberships Pro
<?php
//copy lines 5-19 to your active themes functions.php file or custom plugin
//use the shortcode [members_details] to show information on your post/page
function pmpro_members_details_shortcode( $atts ){
if(is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel()){
global $current_user;
$user_name = $current_user->display_name;
$level_name = $current_user->membership_level->name;
$expiration_date = date("d-m-Y", $current_user->membership_level->enddate);
if( !isset($current_user->membership_level->enddate) || empty($current_user->membership_level->enddate)){
$expiration_date = 'Never'; //Change this line for the expiry date if level never expires
}
return sprintf(__('Hi %s, <br/><br/>Membership: %s<br/>Your membership expires: %s', 'pmpro'), $user_name, $level_name, $expiration_date);
}else{
return __("You do not have a level", "pmpro");
}
}
add_shortcode( 'members_details', 'pmpro_members_details_shortcode' );
?>
@boy1der
Copy link

boy1der commented Jun 2, 2016

This plugin is awesome and I'm currently using it on my site for the benefit of my members. I have a question/request. Is there a way to include in your Members Details code, an added text field that I have using the "Extra User Details" plugin. That text field is for "Member Numbers". I issue each Member a Member Number when they or I register them.

Thanks for any and all help,
boy1der

@andrewlimaza
Copy link
Author

hi @boy1der

Please could you open up a support thread on the PMPro forums and one of our team members will assist you (Most likely will be me). I apologize for the late response, I didn't receive a notification for your comment. I will also relay to the development team that there is quite a bit of interest in this gist and maybe we can create a small plugin that does this for us.

Again, my apologies for the late response to this (I stumbled across this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment