Block Editor Usage
Using the Block Editor (Gutenberg)
The [user_role] shortcode is fully compatible with the WordPress Block Editor. You can display the current user's role anywhere within your posts, pages, or widget areas by following these steps.
Adding via the Shortcode Block
The most reliable way to implement the display is using the dedicated Shortcode block:
- Open the post or page where you want to display the user role.
- Click the (+) Insert button to add a new block.
- Search for Shortcode and select it.
- In the text field provided, enter:
[user_role] - Update or Publish your page.
Adding via the Paragraph Block
Because WordPress automatically parses shortcodes within standard text components, you can also include the role display inline with other content:
- Create a standard Paragraph block.
- Type your desired text, including the shortcode where you want the role to appear.
- Example:
Hello, you are currently logged in as a [user_role].
- Example:
- Save the page.
Expected Output
On the frontend of your website, the shortcode will be replaced by the display name of the current user's role. For example:
- Administrator
- Editor
- Subscriber
[!NOTE] The Block Editor (backend) typically displays the shortcode tag itself (
[user_role]) as a placeholder. To see the actual role output, you must view the page on the live frontend.
Usage in Template Parts and Widgets
If you are using a Block-based theme (FSE), you can also use this shortcode in:
- Header/Footer Template Parts: To show the role in the site navigation area.
- Sidebar Widgets: Using the Shortcode block within the Site Editor's widget areas.