If you’ve ever wanted to do custom CSS based on a user’s Wishlist Member level, this post is for you.
You can add the following code to your functions.php and you will have css classes output to your body tag, leaving you free to do whatever crazy CSS your little heart desires!
/*======================================================================== 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; }
Enjoy!
Leave a Reply