• Resolved handmadehome

    (@handmadehome)


    Hi,

    I want to add a special user role and I wish users can see it. Would it be possible to display user role on my account page? Or maybe, alternatively, there is a way to add an image/badge depending on user role on my account dashboard?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Omar ElHawary

    (@omarelhawary)

    Hi @handmadehome,

    Thanks for reaching out Members Support Team!

    Please copy/paste PHP snippet below WP Code plugin or theme functions.php to use [members_user_role] shortcode to display user roles.

    function display_members_user_role() {
    if (is_user_logged_in()) {
    $current_user = wp_get_current_user();
    $roles = $current_user->roles;

    return !empty($roles) ? esc_html(implode(', ', $roles)) : 'No roles assigned';
    } else {
    return 'User not logged in';
    }
    }
    add_shortcode('members_user_role', 'display_members_user_role');

    For display images/content based on user role? I recommend checking Shortcodes.

    Regards,

    Thread Starter handmadehome

    (@handmadehome)

    Thank you so much!

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