Last active
December 28, 2017 20:45
-
-
Save chrismcintosh/964d9f44f777dfec2ff3c2e10ec4d5d2 to your computer and use it in GitHub Desktop.
If you need to target specific elements with css based on membership level in paid memberships pro here's a snippet.
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 | |
/* Dont Include This Comment or the opening <?php tag */ | |
/************************************* | |
* | |
* Add a body class correlating to the users | |
* memberhsip level in Paid Memberships Pro | |
* looks like - 'member-level-1' | |
* | |
**************************************/ | |
add_filter( 'body_class', 'add_paid_member_body_class' ); | |
function add_paid_member_body_class($classes) { | |
if ( is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && pmpro_hasMembershipLevel() ) { | |
global $current_user; | |
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); | |
$classes[] = 'member-level-' . $current_user->membership_level->id; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment