• Resolved Chris

    (@lamordnt)


    I am using a custom profile template and would like to show the role of the user profile being viewed. So if I am logged into my account and viewing ANOTHER users profile I want to be able to see their role. I have tried using the following code refrenced onthe get_role page with no luck:

    <?php
     um_fetch_user( 12 );
     if ( $ultimatemember->user->get_role() == 'paid-member' ) {
     // Show this to paid customers
     } else {
     // You are a free member
     }
     ?>

    How can I get this to display the role of the profile of the user being viewed?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Chris

    (@lamordnt)

    OK I am getting closer….

    This works:

    <?php if ( UM()->user()->get_role() == 'community_member' ) {?>
     Community Member
    <?php }?>

    If the user’s primary role is “community_member” the above code works. But when I assign multiple roles to my users I cannot get this to work on the secondary role. For example if “board_member” is a secondary user role assigned to a user the above code won’t work.

    ThoughtS?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @lamordnt

    You can put it with an array:

    
    <?php if ( in_array( um_user("role"), ['community_member','another_member_role'] ) ) {?>
     Community Member
    <?php }?>
    

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @lamordnt

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.