Role Colors
-
Hi, 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 } }Unfortunately, while this doesn’t cause an error, it does not display anything under the profile username so I’m probably doing something wrong. Any help is greatly appreciated.
The topic ‘Role Colors’ is closed to new replies.