• Resolved KG

    (@borggunnar)


    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 to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @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

    (@borggunnar)

    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

    (@borggunnar)

    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.