Common Display Issues
Common Display Issues
If you have implemented the [user_role] shortcode but are not seeing the expected output on your site, consult the troubleshooting steps below.
Shortcode appears as literal text
If you see the text [user_role] on your page instead of a user role, it means the shortcode is not being processed by WordPress.
- Check
functions.php: Ensure you have correctly copied the code fromapp.phpinto your active theme'sfunctions.phpfile. - PHP Opening Tags: If you appended the code to the end of an existing file, ensure you did not accidentally nest
<?php ... ?>tags or leave the code outside of the opening tag. - Widget Support: If you are using the shortcode inside a Sidebar or Footer widget, older versions of WordPress may require a filter to enable shortcodes in widgets. Add this to your
functions.php:add_filter('widget_text', 'do_shortcode');
Role is not displaying (Empty output)
If the area where the shortcode is placed is blank, the most common cause is the user's authentication state.
- Logged-out Users: By default, guests (non-logged-in users) do not have a WordPress role. The shortcode will return an empty string because there is no user data to fetch.
- Testing Tip: Always test the shortcode while logged into an account with a specific role (e.g., Subscriber, Editor, or Administrator).
Displaying "Administrator" for all tests
If you are testing the site while logged in as the site owner, the shortcode will correctly display "Administrator." To verify it works for other roles:
- Open your site in an Incognito/Private browser window.
- Log in with a test account assigned a different role (e.g., "Subscriber").
- Check the frontend display.
Styling and Formatting
The shortcode returns the raw role name string without any HTML wrappers. If the role name looks unformatted or is crashing into other text:
- Wrap in HTML: You can wrap the shortcode in HTML tags within your editor to apply specific styles:
<strong>Current Role: [user_role]</strong> - CSS Conflicts: If the text is invisible, check if your theme’s CSS is setting the text color to match the background color in that specific section.
Role names appear in lowercase
The snippet retrieves the internal WordPress slug for the role (e.g., administrator instead of Administrator). If you wish to capitalize the output, you would need to modify the return statement in your functions.php to use the ucfirst() PHP function.
Still having trouble? If you have verified the steps above and the role is still not appearing, please contact us at hello@supervised.co for further assistance.