Role Colors
-
Hi. First of all, awesome plugin. Works great. I am running a website with Ultimate Member and WpDiscuz which allows users to select a role during registration. On Wpdiscuz, there is the option to display different colors depending on the user’s role. I have been trying to place a similar function in the Ultimate Member profiles that changes the color of the user’s name in the header to their corresponding role color and display a specific image underneath their name. I tried searching for UM and WpDiscuz hooks designed for this but found none so I have been attempting to use the following code in my theme’s functions.php file but without any luck:
add_action( 'um_after_profile_header_name_args', 'my_after_profile_header_name_args', 10, 1 ); function my_after_profile_header_name_args( $args ) { $user = new WP_User( $user_id ); $user_roles = $user->roles; $user_role = array_shift($user_roles); if (in_array("um_rank1", $user_roles)) { ?> <div align="center"> <img src="../images/misc/rank1.png" width="250px"> </div> <?php } elseif (in_array("um_rank2", $user_roles)) { ?> <div align="center"> <img src="../images/misc/rank2.png" width="250px"> </div> <?php } elseif (in_array("um_rank3", $user_roles)) { ?> <div align="center"> <img src="../images/misc/rank3.png" width="250px"> </div> <?php } }
If there is a specific block of code from WpDiscuz that can achieve this or any step in the right direction is greatly appreciated. Thank you.
- The topic ‘Role Colors’ is closed to new replies.