• I have a role called “sales” I’d like to check from the front end. If the logged in user has a role of “sales” I’d like to display a welcome message. If not, no message. I was hoping to check the user role like this:


    <?php
    $user_id = get_current_user_id();
    $user = new WP_User( $user_id );
    if ( $user->roles[0] == 'sales' ) {
    echo '<div style="width:100%; height:200px; background:#f00; margin:0px auto;">Welcome Sales Member</div>';
    }
    ?>

    The code works with native WordPress roles (author, editor, etc.) but not with my custom roles.

    Anybody know how to do this?

    https://www.ads-software.com/plugins/advanced-access-manager/

  • The topic ‘Help checking user role on frontend’ is closed to new replies.