Have you ever wanted to do some custom CSS for your website’s users based on what Wishlist membership level they’re in? A good example of this would be hiding nav items for certain wishlist member levels. All you have to do is paste the code below in your functions.php file and it will add a class to the nav for each level the member is in.
Enjoy!
/*======================================================================== Add a body class for each of a user's membership levels ========================================================================*/ add_filter( 'body_class', 'wlm_body_classes' ); function wlm_body_classes( $classes ) { $user_ID = get_current_user_id(); $levels = wlmapi_get_member_levels($user_ID); foreach($levels as $level){ $level_id = $level->Level_ID; // add the level to the $classes array $classes[] = 'wlm-level-' . $level_id; } // return the $classes array return $classes; }
Leave a Reply