Try to do this:
<?php global $current_user;?>
<?php if(is_user_logged_in()) :?>
<?php get_currentuserinfo();?>
<?php if(is_array( $current_user->roles ) && in_array( 'map_user', $current_user->roles ) ) : ?>
<div id="mapContent">
<?php require("/mapping/".$current_user->user_login.".html/"); ?>
</div>
<?php endif; ?>
<?php endif; ?>
Source codex.wordpress.org
Related Posts:
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- Do not execute If User is login as Administrator or any Specific Role
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Add another role to a user when they click a button?
- How to connect database table to each registered wordpress user.
- Get author meta of all writers
- Forbid certain users to access a specific page
- How to lock users account until approvation
- How to create a User Role and give permission to only use Web Stories plugin?
- How to create custom user role without plugin?
- Custom Admin Menu Report for Specific User ID
- How to add custom user role into wordpress
- Remove update nags for non-admins [duplicate]
- wp_insert_user role not working
- Create a global variable for use in all templates
- Display user’s total comment count outside The Loop
- Changing user_nicename
- How to auto login user again after change user_login
- Can i check if user is doing any ajax request?
- How do I create a WP user outside of WordPress and auto login?
- wordpress separate registration for different roles
- How to track a users progress through pages by inserting data into WordPress Database?
- automated tests as a user?
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Display user role Name – not slug
- Warning: Use of undefined constant HTTP_USER_AGENT – assumed ‘HTTP_USER_AGENT’ (this will throw an Error in a future version of PHP)
- Get all user meta by meta key instead of ID
- User’s total comment count excluding comments on their own posts
- User management system similar to wordpress one?
- Show all posts by author
- Error when adding excerpt to the content through functions.php
- Programmatic Login from 3rd Party site
- Add New User, extra fields which are required?
- Modify user profile data through scripting?
- Get users that likes the post
- Best practice for show data to one specific user?
- get_users meta_query: REGEXP not working for matching new lines
- “operation successful” message
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Add post with approval by the admin
- php if username is role
- Is it possible to create new user from external form using REST API?
- Foreach loop inside an array_merge
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Show current user posts only
- Array to string conversion error in PHP 7.2 when returning user role as class
- Change page password every day (predictable password ;) )
- show something only when user comes from specific page at remote host?
- Noindex subscriber author page
- Display an image based on field value
- Show site content based on user role
- ‘pre_user_query’ interfering with user export
- WordPress Twenty Eleven PhP – forcing php code to skip first post on homepage?
- Redirect to current user page upon link click
- Plugin: Front-end Editor – User role specific editable content?
- search and add in wordpress content
- Execute PHP code only with specific user role
- For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?
- Generate a QR code when creating a new WordPress user
- Execute function only for specific user roles
- Sort new column in Users wp-admin
- Sort column in Users admin Tab
- Woocommerce display orders with products from specific categories to specific admins
- Admin Panel 404 Error after login
- Hide payment method based on user role AND minimum cart value
- How to count active users on a specific page
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- Edit a function to take different actions based on user role
- If user has clicked link add class and store using PHP/WordPress
- Store data from JavaScript object to custom table in user account
- Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]
- How to change the value of a variable using input field?
- How do I track which user clicked my button?
- How to give custom roles the capability to edit one Menu instead of every Menu
- Trying to modify content.php
- Use WP user status (logged_in) to manage access to independent application
- Query to show average # of months all accounts with specific role have been active
- dynamically change content of div with php
- Echo Option Value Based On WordPress User Role
- Editable Student file associated with basic User ID
- Adding users to another blog
- Role exception for a settings sub menu
- Matching multi user
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Updating custom user meta
- Allow BBPress participant role to trash topics
- Update only some custom user fields
- Add end mark at the end of every article
- main menu page redirects to user ID
- Editing the contents of just one div on a page from wordpress
- Adapting a php array to WordPress
- Overwriting a Shortcode
- Let users register weight each day and save it in DB
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- Switch-Case and user_role
- Encode code snippet in AJAX endpoint
- Import users and custom user meta from csv
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Getting invalid user ID error when creating a new user with wp_insert_user
- PHP Works only for logged in users: [closed]