• WP Craftbench

    (@kadecooper)


    Is there a method to show the user role using a shortcode? I need the user name and role to show at the top of each page

Viewing 1 replies (of 1 total)
  • Plugin Support mansurahamed

    (@mansurahamed)

    Hi @kadecooper,

    Sorry, there is not built-in shortcode for that at this moment. You can use a plugin like https://ve.ww.wp.xz.cn/plugins/insert-php-code-snippet/ to create a shortcode from following php code

    um_fetch_user( $user_id);
    $roles = um_user('roles');
    foreach($roles as $role){
    echo $role;
    }
    

    In the above code set $user_id to get_current_user_id() if you want to get the roles of current logged in user.

    Thanks.

Viewing 1 replies (of 1 total)

The topic ‘Shortcode to show user role’ is closed to new replies.