Title: Shortcode for UM role
Last modified: November 24, 2020

---

# Shortcode for UM role

 *  Resolved [KG](https://wordpress.org/support/users/borggunnar/)
 * (@borggunnar)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-um-role/)
 * I am looking for the short-code for displaying the user role and place it anywhere.
   It surprise me that the plugins pre-build pages does not show the user’s role,
   e.g. subscriber, member, and whatever roles you have defined.
 * One is able to control content by user role and show/hide content and navigation
   links. But user roles don’t even show on the profile pages…
 * Anyone..
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcode-for-um-role%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-um-role/#post-13706260)
 * Hi [@borggunnar](https://wordpress.org/support/users/borggunnar/)
 * You can try this in your theme functions.php file or using a Code Snippet plugin:
 *     ```
        add_shortcode("um_role", function(){
   
           um_fetch_user( um_profile_id() );
   
           return um_user("role");
        });
       ```
   
 * Now, you can use this shortcode: `[um_role]`
 * Regards,
 *  Thread Starter [KG](https://wordpress.org/support/users/borggunnar/)
 * (@borggunnar)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-um-role/#post-13706868)
 * Hi Champ,
 * Many thanks! I use the wordpress.com hosting, and not so tech-savvy, I am not
   sure where to place the code. Would there be a CSS equivalent of the code?
 * Regards,
 * G
 *  Thread Starter [KG](https://wordpress.org/support/users/borggunnar/)
 * (@borggunnar)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-um-role/#post-13707085)
 * Hi Champ,
 * I just tried this:
    [um_show_content roles=’um_starter-member’]Your membership:
   Starter Member[/um_show_content]
 * [um_show_content roles=’um_recognized-member’]Your membership: Recognized Member[/
   um_show_content]
 * [um_show_content roles=’um_contributor-member’]Your membership: Contributor Member[/
   um_show_content]
 * And that works although looks clumsy. Would like, similarly, to display the user
   name. With the short-code above or similar, and the name, I can indeed personalize
   the content based on user name and role.
 * Cheers,
 * G

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode for UM role’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [KG](https://wordpress.org/support/users/borggunnar/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/shortcode-for-um-role/#post-13707085)
 * Status: resolved